Skip to content

Conversation

@anders-swanson
Copy link
Member

Override Existing, Individual Metrics

You may override properties for existing metrics by supplying a new, custom metric definition with the same context and metricsdesc values. For example, if you have an existing metric like so:

[[metric]]
context = "my_default_metric"
metricsdesc = { value_1 = "Simple example returning always 1.", value_2 = "Same but returning always 2." }
request = "SELECT 1 as value_1, 2 as value_2 FROM DUAL"

You can redefine this metric in a custom metrics file to change any properties other than context or metricsdesc. For example, overriding the previous metric with labels, scrapeinterval, and querytimeout properties:

[[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 FROM DUAL"
scrapeinterval = "30s"
querytimeout = "10s"

Then, provide any metrics overrides as custom metrics files in the exporter configuration file:

metrics:
  ## Paths to any custom metrics files
  custom:
    - my-custom-metrics.toml

If any metric appears more than once in the custom metrics file list, the metric definition in the last file provided takes precedence.

Signed-off-by: Anders Swanson <anders.swanson@oracle.com>
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Sep 26, 2025
@anders-swanson
Copy link
Member Author

Previously, behavior for duplicate metrics was undefined. This also fixes that issue, merge-replacing duplicate metrics.

@anders-swanson
Copy link
Member Author

Fixes #375

@anders-swanson anders-swanson merged commit 568ee42 into main Sep 29, 2025
1 check passed
@anders-swanson anders-swanson deleted the hot-reload-override-metric branch September 29, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Verified All contributors have signed the Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants