Skip to content

Multiple custom metrics files overwrite one another #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Sycri opened this issue Feb 24, 2025 · 3 comments
Closed

Multiple custom metrics files overwrite one another #179

Sycri opened this issue Feb 24, 2025 · 3 comments
Assignees

Comments

@Sycri
Copy link

Sycri commented Feb 24, 2025

If multiple files for custom metrics are specified using environment variable CUSTOM_METRICS, then upon loading metrics in

if _, err := toml.DecodeFile(_customMetrics, &additionalMetrics); err != nil {
the variable additionalMetrics is reused from
additionalMetrics Metrics
and overwritten when reading from the second file for custom metrics.

The problem seems to be caused by the fact that metrics are read from that same variable additionalMetrics and due to it being type Metrics which itself is a struct that contains a slice of struct Metric, it is all being reused and therefore overwritten when the second file for custom metrics is read.

Example:
File docker-compose.yaml

services:
  oracledb_exporter:
    image: container-registry.oracle.com/database/observability-exporter:1.5.3
    command: --log.disable=1 --log.level=debug
    volumes:
      - ./custom-metrics.toml:/custom-metrics.toml
      - ./custom-metrics-2.toml:/custom-metrics-2.toml
    environment:
      - TZ=
      - CUSTOM_METRICS=/custom-metrics.toml,/custom-metrics-2.toml
      - DATABASE_MAXIDLECONNS=1
      - DATABASE_MAXOPENCONNS=1
      - DB_USERNAME=
      - DB_PASSWORD=
      - DB_CONNECT_STRING=
      - QUERY_TIMEOUT=10
    ports:
      - "9161:9161"

File custom-metrics.toml

[[metric]]
context = "test_1"
ignoreZeroResult = true
metricsdesc = { value = "Test 1" }
labels = [ "test1_desc" ]
request = "select 'TEST 1' as test1_desc, 11 as value from dual"

File custom-metrics-2.toml

[[metric]]
context = "test_2"
ignoreZeroResult = true
metricsdesc = { value = "Test 2" }
labels = [ "test2_desc" ]
request = "select 'TEST 2' as test2_desc, 22 as value from dual"

Results:
Image

@markxnelson
Copy link
Member

Thanks very much for reporting @Sycri

@anders-swanson anders-swanson self-assigned this Feb 28, 2025
@anders-swanson
Copy link
Member

Fixed in main, will be released in 1.5.4. Thanks!

@markxnelson
Copy link
Member

We believe we have this fixed in 1.5.4 - if you still see the error, please reopen, or open a new issue to let you know. Thanks very much for your input.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants