LinkMesh

Search docs, blog and changelog

ENDE
LinkMeshObservability Data Collection Management
OpenTelemetryObservability

Oracle Database → Grafana

Sessions, tablespaces, locks and the alert log, next to everything else you monitor.

linkmesh.io
Philippe BraxmeierPhilippe Braxmeier← Back to blog
10 min read

Oracle Database measures itself in detail. The numbers sit in the V$ views, in Enterprise Manager and in AWR reports, and that is where they stay. The team that runs Grafana for everything else sees the database as a host with CPU and disks, and nothing of what happens inside it.

The OpenTelemetry Collector has a receiver that reads those views over a normal database connection and turns them into metrics. This guide sets it up: a monitoring user, the collector configuration, the alert log, and the same pattern for SQL Server and SAP HANA.

Who this guide is for

Database administrators and platform teams that run Oracle Database on their own infrastructure and use Grafana, or plan to. You need the right to create a database user, a host that can reach the listener, and a Grafana target (Grafana Cloud’s free tier is fine).

What you’ll have when you’re done

  • Sessions, processes, transactions and locks against their limits, with history, so you see a limit coming before the database refuses connections.
  • Tablespace usage per tablespace, next to its maximum size.
  • Workload counters: executions, parses and hard parses, logical and physical reads, commits and rollbacks, CPU time.
  • The alert log searchable in one place, across all databases.
  • Optionally, top queries and wait events as log records.

How it maps to what you already use

Nothing here is a new measurement. It is what Oracle already records, sent to Grafana:

You know it as… Oracle keeps it in… The metric is called
Sessions and processes against their limits V$SESSION, V$RESOURCE_LIMIT oracledb.sessions.usage, oracledb.sessions.limit, oracledb.processes.usage, oracledb.processes.limit
Tablespace usage in Enterprise Manager DBA_TABLESPACE_USAGE_METRICS, DBA_TABLESPACES oracledb.tablespace_size.usage, oracledb.tablespace_size.limit
The load profile of an AWR report V$SYSSTAT oracledb.executions, oracledb.hard_parses, oracledb.logical_reads, oracledb.physical_reads, oracledb.user_commits
Locks and deadlocks V$RESOURCE_LIMIT, V$SYSSTAT oracledb.dml_locks.usage, oracledb.enqueue_deadlocks
The alert log alert_<SID>.log in the diagnostic repository Log records

An OpenTelemetry Collector connects to the Oracle listener as a database client and reads the V$ and DBA views with the oracledb receiver. A filelog receiver reads the alert log, which needs a collector on the database host. The collector sends metrics to Prometheus or Mimir and logs to Loki, and Grafana reads both. A LinkMesh control plane manages the collector configuration over OpAMP. No telemetry passes through LinkMesh.

Figure 1. The receiver is a database client. Only the alert log needs a collector on the database host.

Step 1 — Create a monitoring user

The receiver needs a user that can log in and read a handful of views. These grants cover the metrics that are on by default and the instance details the receiver adds to every metric:

CREATE USER otel IDENTIFIED BY "<password>";
GRANT CREATE SESSION TO otel;

GRANT SELECT ON V_$SESSION TO otel;
GRANT SELECT ON V_$SYSSTAT TO otel;
GRANT SELECT ON V_$RESOURCE_LIMIT TO otel;
GRANT SELECT ON V_$OSSTAT TO otel;
GRANT SELECT ON V_$SGAINFO TO otel;
GRANT SELECT ON DBA_TABLESPACES TO otel;
GRANT SELECT ON DBA_DATA_FILES TO otel;
GRANT SELECT ON DBA_TABLESPACE_USAGE_METRICS TO otel;

GRANT SELECT ON V_$INSTANCE TO otel;
GRANT SELECT ON V_$DATABASE TO otel;

In a multitenant database, create the user in the pluggable database you connect to. To see every pluggable database from the container root, the receiver needs a common user and container-wide grants. The receiver’s README lists them, together with the grants for ASM and for Amazon RDS.

Step 2 — Install the collector where it can reach the listener

The receiver is a database client. It connects to the listener like any application, so the collector does not have to run on the database host. One collector on a monitoring host can watch several databases. The alert log in Step 4 is the exception, because it is a file.

Install the contrib distribution from the official releases. The Oracle receiver ships there. Its driver is written in Go, so you do not install an Oracle client. Pin the release you install. The examples below follow the receiver’s documentation for contrib v0.165.0.

Step 3 — Configure the receiver

receivers:
  oracledb:
    endpoint: db01.example.internal:1521
    service: ORCLPDB1
    username: otel
    password: ${env:ORACLE_PASSWORD}
    collection_interval: 60s

processors:
  memory_limiter:
    check_interval: 1s
    limit_percentage: 80
    spike_limit_percentage: 25

exporters:
  otlphttp/grafana:            # where the data goes: paste your values here
    endpoint: "https://otlp-gateway-<zone>.grafana.net/otlp"
    headers:
      Authorization: "Basic <base64 of instanceID:token>"
    sending_queue:
      enabled: true
      batch:
        enabled: true

service:
  pipelines:
    metrics:
      receivers: [oracledb]
      processors: [memory_limiter]
      exporters: [otlphttp/grafana]
  • endpoint and service are the listener address and the service name, the same values an application uses.
  • password comes from an environment variable and never sits in the file. See managing secrets in collector config.
  • collection_interval defaults to 10 seconds. One minute is enough for capacity metrics and sends fewer queries to the database.
  • exporters is the destination. In Grafana Cloud you find both values under Connections → OTLP.

Self-hosting Grafana? Replace the exporter with prometheusremotewrite to Prometheus or Mimir. Nothing else changes.

Two more things are worth knowing. The receiver has 25 metrics switched on and about 110 more that you enable by name, for example for ASM disk groups or the SGA. And one collector can watch several databases: add one receiver per database, named oracledb/erp, oracledb/crm and so on, and list them all in the pipeline.

Step 4 — Add the alert log

The alert log is a text file in the diagnostic repository. To find the directory, ask the database:

SELECT value FROM v$diag_info WHERE name = 'Diag Trace';

A collector on the database host reads the file with the filelog receiver:

extensions:
  file_storage:
    directory: /var/lib/otelcol/storage
    create_directory: true

receivers:
  filelog/oracle-alert:
    include:
      - /u01/app/oracle/diag/rdbms/*/*/trace/alert_*.log
    start_at: end
    storage: file_storage
    multiline:
      line_start_pattern: '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}'

service:
  extensions: [file_storage]
  pipelines:
    logs:
      receivers: [filelog/oracle-alert]
      processors: [memory_limiter]
      exporters: [otlphttp/grafana]
  • multiline keeps an entry together. Since Oracle Database 12.2 every entry starts with a timestamp line, followed by one or more message lines. Older releases write the timestamp in another format, so adjust the pattern there.
  • storage remembers how far the file was read, so a restart does not send the log twice.
  • The user the collector runs as needs read access to that directory.

Step 5 — Check that it works

  1. Run otelcol-contrib validate --config config.yaml. It reports a typo before the service starts.
  2. Start the collector and read its own log. A wrong password or a missing grant shows up there as an ORA- error within the first interval.
  3. Open Grafana → Explore, pick your metrics data source and search for oracledb. The names arrive with underscores, for example oracledb_sessions_usage.
  4. Switch to Loki and search the alert log for ORA-.

Step 6 — Build the dashboard

Six panels answer most of what an on-call administrator asks first:

  • Sessions and processes against their limit. oracledb.sessions.usage over oracledb.sessions.limit, and the same pair for processes. Alert well before 100 %. A limit of -1 means unlimited.
  • Tablespace used. oracledb.tablespace_size.usage over oracledb.tablespace_size.limit, per tablespace.
  • Hard parses. The rate of oracledb.hard_parses next to oracledb.parse_calls. A high share of hard parses usually points to statements without bind variables.
  • Logical and physical reads. oracledb.logical_reads and oracledb.physical_reads as rates.
  • Commits and rollbacks. oracledb.user_commits and oracledb.user_rollbacks.
  • Deadlocks. Any increase of oracledb.enqueue_deadlocks deserves a look.

Add a logs panel with the ORA- lines of the alert log under them, and the first question after an alert is answered on the same screen.

Step 7 — Optional: top queries and wait events

The receiver can also report the most expensive queries, samples of running queries, wait events per session and the top stored procedures. These arrive as log records, they are switched off by default, and the receiver rates them as in development:

receivers:
  oracledb:
    # connection settings as in Step 3
    events:
      db.server.top_query:
        enabled: true
      db.server.session.wait_sample:
        enabled: true

They need more grants, among them V_$SQL, V_$SQL_PLAN_STATISTICS_ALL and V_$SESSION_EVENT. The receiver obfuscates the SQL text before it reports it. Look at a sample anyway before you send these records to a shared backend, and mask what should not leave.

The same pattern for SQL Server and SAP HANA

  • SQL Server. The sql_server receiver (sqlserver in older releases) is rated beta for metrics. It reads Windows performance counters on the host, or connects directly with server, port, username and password. A direct connection needs the right to see the databases and the server state: VIEW SERVER STATE, or VIEW SERVER PERFORMANCE STATE from SQL Server 2022. The counter route is described in Monitor Windows Server with OpenTelemetry and Grafana.
  • SAP HANA. The saphana receiver is rated alpha and is meant for HANA 2. It needs a restricted user with read access to the monitoring views. Its README has the script.
  • Everything else. The sqlquery receiver runs your own SQL and turns columns into metrics or log records. It has drivers for Oracle, SQL Server, SAP HANA, SAP ASE, PostgreSQL, MySQL, Snowflake and ClickHouse.

Step 8 — Many databases: manage the collectors with LinkMesh

One database is a file you edit. Twenty databases in test and production, each with its own credentials and a collector on each database host for the alert log, are a fleet. Editing YAML over SSH on every host is where such a setup starts to drift.

The collector speaks OpAMP, so it can be managed centrally. LinkMesh is a self-hosted control plane for exactly this. You enrol each collector with a token and put the database hosts into collector groups that share a configuration. Where the source catalog has no template for a receiver, you add it as a custom source: you write the receiver’s settings as YAML once, and LinkMesh places them in the generated configuration and rolls it out. Every change is previewed, versioned and audited.

The telemetry still flows straight from each collector to Grafana and stays on your network. LinkMesh only manages the configuration, and it is priced per managed collector, not per gigabyte.

Troubleshooting

  • ORA-01017 (invalid username or password). If you use the datasource form of the configuration, special characters in the password must be URL-encoded. With the separate password field they are allowed as they are.
  • ORA-12514 (listener does not know the service). service takes the service name, not the SID. lsnrctl status lists the services.
  • ORA-00942 (table or view does not exist). A grant from Step 1 is missing.
  • No tablespace metrics. The three DBA_ grants are missing.
  • Different limits on a pluggable database. Connected directly to a pluggable database, the receiver reads the limits for transactions and DML locks from another view than at the container root, and the values can differ.

Two limits to keep in mind. In contrib v0.165.0 the receiver is rated alpha for metrics, so names and settings can change between releases. Pin the version and read the release notes before you upgrade, as described in keeping a collector fleet up to date. And it does not replace AWR or Enterprise Manager for diagnosis. It puts the health of the database next to the rest of your estate, so the first look happens in one place.

More than a handful of databases?

LinkMesh manages the collector on every host from one self-hosted control plane: define the source once, preview the configuration and deploy it over OpAMP, with an audited rollout, priced per collector rather than per gigabyte. Stand one up in minutes, or see what it does.