Oracle AI Database Metrics Exporter

repository·main·Indexed 42 days ago

https://github.com/oracle/oracle-db-appdev-monitoring

An observability tool designed to collect and export performance metrics from Oracle AI Databases to Prometheus or OpenTelemetry (OTLP) backends. It supports alert log exporting, custom metric configurations via TOML, and flexible deployment options including Docker and Go binaries. The exporter provides support for both the standard godror driver and the thin go-ora database driver.

Tokens
21.3K
Snippets
74
Records
97
Agent score
53%

What's inside Oracle AI Database Metrics Exporter

  1. Overview of Oracle AI Database Metrics Exporter

    main

    The Oracle AI Database Metrics Exporter is a tool designed to monitor the health, performance, and availability of Oracle AI Database instances. It allows you to collect metrics from one or more databases using a single exporter instance and provides multiple delivery paths:

    • Prometheus Format: Exposes metrics on the default /metrics endpoint.
    • OpenTelemetry (OTLP/gRPC): Publishes metrics directly to an OpenTelemetry backend.

    The exporter is designed to work across various environments, including on-premises, cloud, and Kubernetes, supporting single instances, clusters, or Autonomous Oracle AI Database instances. It ensures that if one database goes offline for maintenance, other monitored databases remain active.

  2. Understand the exporter initialization lifecycle

    main

    The exporter is a Go program built with the Prometheus SDK. During startup (primarily within the main function), it follows this sequence:

    1. Configuration Parsing: Parses the --config.file option and associated configuration properties.
    2. Metric Loading: Loads the default default-metrics.toml file, storing metrics in Metric structs, and then overlays any provided custom TOML file.
    3. Exporter Setup: Creates an Exporter object and registers it with the Prometheus library.
    4. Server Startup: Launches a web server to listen for incoming requests.
    5. Database Connection: Attempts to connect to the configured Oracle AI Database servers.

    Once initialized, the exporter waits for scrape requests. When a request arrives, it iterates through the metricsToScrape structure. For each Metric, it calls ScrapeMetric, which invokes ScrapeGenericValues. This function uses GeneratePrometheusMetrics to execute SQL calls against the database to retrieve the required data.

  3. Override existing metrics

    main

    You can override properties of an existing metric (like scrapeinterval, querytimeout, or labels) by providing a new definition in a custom metrics file that uses the exact same context and metricsdesc values. This allows you to refine existing metrics without redefining the entire logic.

    [[metric]]
    context = "my_default_metric"
    metricsdesc = { value_1 = "Simple example returning always 1.", value_2 = "Same but returning always 2." }
    labels = [ "label_1", "label_2" ]
    request = "SELECT 1 as value_1, 2 as value_2, 'val' as label_1, 'val' as label_2 FROM DUAL"
    scrapeinterval = "30s"
    querytimeout = "10s"
  4. Key Features of the Metrics Exporter

    main

    The exporter provides several capabilities for monitoring and security:

    Metric Delivery & Customization

    • Dual Delivery: Supports both Prometheus /metrics endpoint and OTLP/gRPC publishing.
    • Custom Metrics: Define custom metrics using YAML or TOML files.
    • Granular Configuration: Customize scrape intervals, database query timeouts, and other parameters on a per-metric or per-database level.
    • Alert Logs: Exports the Prometheus Alert Log in JSON format for log aggregators.

    Connectivity & Security

    • Authentication: Supports plaintext, TLS, and Oracle Wallet.
    • Secret Management: Secure credentials using OCI Vault, Azure Vault, or HashiCorp Vault.
    • Connection Pooling: Supports go-sql, Oracle AI Database connection pools, and Database Resident Connection Pools (DRCP).

    Deployment

    • Platforms: Works with on-prem, cloud, and Kubernetes.
    • Images: Pre-built AMD64 and ARM64 images are available.
    • Integrations: Available as a Grafana Alloy component and includes sample Grafana dashboards.
  5. Use per-database log files for multiple databases

    main

    When scraping multiple databases, it is recommended to set log.perDatabaseFiles: true. This prevents all databases from writing to a single shared file and instead creates individual files following the pattern alert-<db>.log.

    For example, if log.destination is set to /opt/exporter/alert.log and a database is named db2, the log will be written to /opt/exporter/alert-db2.log.

  6. Filter metrics by specific databases

    main

    By default, every metric is scraped from all connected databases. You can restrict a metric to specific databases by defining a databases array within the metric configuration.

    • If databases is an array of names (e.g., [ "db2", "db3" ]), the metric is only scraped from those specific databases.
    • If databases is empty or omitted, the metric is scraped from all connected databases.
    [[metric]]
    context = "db_platform"
    labels = [ "platform_name" ]
    metricsdesc = { value = "Database platform" }
    request = '''
    SELECT platform_name, 1 as value FROM gv$database
    '''
    databases = [ "db2", "db3" ]
  7. Understand the cardinality of per-metric scrape duration metrics

    main

    The oracledb_exporter_last_metric_scrape_duration_seconds metric is opt-in because its series count scales with the number of databases monitored. The total number of series is calculated as:

    series = (default metric definitions + custom metric definitions) x databases

    Note that duration is reported per metric definition, not per resulting Prometheus metric. For example, a single definition using fieldtoappend that produces four Prometheus metrics will only produce one duration series.

    Cardinality Examples (based on 12 default metrics):

    DatabasesCustom metricsAdditional series
    1012
    10001,200
    100203,200
    300209,600

    Recommendation: If monitoring a large number of databases, enable this metric temporarily for troubleshooting slow scrapes rather than leaving it enabled permanently.

  8. Configure Oracle Wallet for mTLS

    main

    For mutual TLS (mTLS) connections, you must use an Oracle Wallet.

    1. Set the TNS_ADMIN environment variable to the directory containing your unzipped wallet.
    2. In your configuration, use the TNS name from the wallet's tnsnames.ora file as the url.

    Example Configuration:

    databases:
      mydb:
        username: admin
        password: <REPLACE ME>
        url: <TNS Name>

    Docker Usage: If running as a container, mount the wallet directory as a volume:

    docker run -it --rm \
        -e DB_USERNAME=pdbadmin \
        -e DB_PASSWORD='<your-password>' \
        -e DB_CONNECT_STRING=devdb_tp \
        -v ./wallet:/wallet \
        -p 9161:9161 \
        container-registry.oracle.com/database/observability-exporter:2.5.0
  9. Deploy the website

    main

    You can deploy the website using yarn deploy with different configurations depending on your hosting method:

    • Using SSH: Set USE_SSH=true.
    • Using GitHub Pages: Provide your GitHub username via the GIT_USER environment variable. This will build the site and push it to the gh-pages branch.
    # Using SSH
    USE_SSH=true yarn deploy
    
    # Using GitHub Pages
    GIT_USER=<Your GitHub username> yarn deploy