Database Metrics Exporter 2.0.0

Metrics Exporter dashboard showing gauges, graphs, and statistics

The Oracle Database Exporter 2.0.0 release is out! This major update brings powerful new features to help you monitor Oracle databases more easily and flexibly. In this release, we’ve introduced:

  • A brand-new configuration file format, making setup simpler and more portable.
  • Support for multi-database and per-database metrics, giving you more control over what gets monitored.
  • Configurable metrics per-database
  • Flexible, multi-database support for secure credential loading using OCI Vault and/or Azure Vault
  • Bug fixes and dependency updates!

In this post, we’ll walk you through the new features, show examples, and give a sneak peek at what’s coming next.

Release notes for Oracle Database Monitoring Exporter 2.0.0 highlighting new features, bug fixes, and configuration options.

Configuration File

The metrics exporter now lets you configure all parameters using a file, passed to the exporter using the --config.file argument. Any environment variable of the form ${MY_ENV_VAR} will be substituted as the configuration file is loaded by the metrics exporter.

# Example Oracle Database Metrics Exporter Configuration file.
# Environment variables of the form ${VAR_NAME} will be expanded.

databases:
  ## Path on which metrics will be served
  # metricsPath: /metrics
  ## Database connection information for the "default" database.
  mydb:
    ## Database username
    username: ${DB_USERNAME}
    ## Database password
    password: ${DB_PASSWORD}
    ## Database connection url
    url: localhost:1521/freepdb1

    ## Metrics query timeout for this database, in seconds
    queryTimeout: 5

    ## Rely on Oracle Database External Authentication by network or OS
    # externalAuth: false
    ## Database role
    # role: SYSDBA
    ## Path to Oracle Database wallet, if using wallet
    # tnsAdmin: /path/to/database/wallet

    ### Connection settings:
    ### Either the go-sql or Oracle Database connection pool may be used.
    ### To use the Oracle Database connection pool over the go-sql connection pool,
    ### set maxIdleConns to zero and configure the pool* settings.

    ### Connection pooling settings for the go-sql connection pool
    ## Max open connections for this database using go-sql connection pool
    maxOpenConns: 10
    ## Max idle connections for this database using go-sql connection pool
    maxIdleConns: 10

    ### Connection pooling settings for the Oracle Database connection pool
    ## Oracle Database connection pool increment.
    # poolIncrement: 1
    ## Oracle Database Connection pool maximum size
    # poolMaxConnections: 15
    ## Oracle Database Connection pool minimum size
    # poolMinConnections: 15

metrics:
  ## How often to scrape metrics. If not provided, metrics will be scraped on request.
  #scrapeInterval: 15s
  ## Path to default metrics file.
  default: default-metrics.toml
  ## Paths to any custom metrics files
#  custom:
#    - custom-metrics-example/custom-metrics.toml

log:
  # Path of log file
  destination: /Users/example/alert.log
  # Interval of log updates
  interval: 15s
  ## Set disable to 1 to disable logging
  # disable: 0

We recommend configuring databases using the configuration file, though CLI arguments are still supported in this release. Avoid mixing CLI arguments and the configuration file: it’s recommended to choose one method for configuring the exporter.

Multi-Database Support

Powered by the new configuration format, the metrics exporter can now be configured to concurrently scrape metrics from multiple databases. To configure additional databases, simply add another entry to the databases configuration object:

databases:
  db1:
    url: localhost:1521/freepdb1
    username: ${DB1_USERNAME}
    password: ${DB1_PASSWORD}
  db2:
    url: localhost:1522/freepdb1
    username: ${DB2_USERNAME}
    password: ${DB2_PASSWORD}

You can also load database credentials for multiple databases from OCI Vault or Azure Vault, using vault ids and secret names. Expect to see additional providers supported in the future!

databases:
  db1:
    url: localhost:1521/freepdb1
    vault:
      oci:
        id: ${OCI_VAULT_OCID}
        usernameSecret: ${OCI_VAULT_USERNAME_SECRET}
        passwordSecret: ${OCI_VAULT_PASSWORD_SECRET}
  db2:
    url: localhost:1522/freepdb1
    vault:
      azure:
        id: {AZ_VAULT_ID}
        usernameSecret: ${AZ_USERNAME_SECRET}
        passwordSecret: ${AZ_PASSWORD_SECRET}

Per-Database Metrics

By default, all metrics run on every configured database. However, if you have multiple databases, you may wish to run certain metrics only on specific ones. That’s where per-database metrics come in: just add a list of databases to a metric, and that metric will only run on those databases.

In this example, the “sessions” metric will only be scraped from the “db1” and “db2” databases, and the metric will be ignored for any other databases.

[[metric]]
context = "sessions"
labels = [ "status", "type" ]
metricsdesc = { value= "Gauge metric with count of sessions by status and type." }
request = "SELECT status, type, COUNT(*) as value FROM v$session GROUP BY status, type"
databases = [ "db1", "db2" ]

What’s up next?

We’re continuing to iterate and improve the Database Metrics Exporter, and plan to add the following features in the next release:

  • Transparent RAC support by converting default metrics to use gv$ views instead of single instance v$ view.
  • Exadata support using gv$cell views to monitor Exadata-specific metrics like smart scans, flash cache, and I/O stats.
  • Support for GCP and AWS secrets managers to load database credentials.

Have an idea or feature you’d like to see implemented in the metrics exporter? Log an issue on the open-source GitHub project and we’ll see what we can do!

Leave a Reply

Discover more from andersswanson.dev

Subscribe now to keep reading and get access to the full archive.

Continue reading