Skip to content

SQLEXPORTER_COLLECTOR_FILES not working #830

@TommieGrove

Description

@TommieGrove

Describe the bug

was looking at how i could run different collectors against the same list of target/jobs and noticed SQLEXPORTER_COLLECTOR_FILES can be defined as an environment variable. However, this does not work due to loadCollectorFiles() running before processEnvConfig() in the UnmarshallYAML in config.go.

To Reproduce

export SQLEXPORTER_COLLECTOR_FILES=mssql_test.collector.yml
./sql_exporter

time=2025-10-26T14:26:38.827+02:00 level=ERROR source=main.go:107 msg="Error creating exporter" error="unknown collector \"mssql_*\" referenced in job \"sqlserver01\""

Expected behavior

defining SQLEXPORTER_COLLECTOR_FILES should load the collector file.

Configuration

sql_exporter.yml

jobs:
  - job_name: sqlserver01
    collectors: [mssql_*]
    static_configs:
      - targets:
          sqlserver01: sqlserver://test:test@192.168.15.240:1433/master
  - job_name: sqlserver02
    collectors: [mssql_*]
    static_configs:
      - targets:
          sqlserver02: sqlserver://test:test@192.168.15.240:1433/master

Additional context

switching loadCollectorFiles() and processEnvConfig() around, the exporter runs successfully with SQLEXPORTER_COLLECTOR_FILES set

sql_exporter.yml
mssql_test.collector.yml

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions