Skip to content
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

Exclude database label at exporter level #173

Open
robbat2 opened this issue Nov 10, 2023 · 3 comments
Open

Exclude database label at exporter level #173

robbat2 opened this issue Nov 10, 2023 · 3 comments

Comments

@robbat2
Copy link

robbat2 commented Nov 10, 2023

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
I want to avoid exporting a meaningless label for database.

Present state

mymetric{database="db",label1="value1"} NNNN

Describe the solution you'd like
Require users to explicitly declare the database label in the config.

Desired state:

mymetric{label1="value1"} NNNN

Describe alternatives you've considered
label drop in Prometheus/Mimir/VictoriaMetrics is possible, but has to be configured on every scraper.

Additional context
The present design implicitly breaks anybody who ever wanted their own label of database.

@albertodonato
Copy link
Owner

Can't you either name the database as desired in the config (so that it shows as label value), or use a different label name to aggregate as desired?

@robbat2
Copy link
Author

robbat2 commented Jan 16, 2024

In the README sample configuration and output, there's this example:

queries_total{app="app1",database="db1",query="query1",region="us1",status="success"} 50.0

The database label is NOT declared in the labels section of the config, and there's no direct way in the config to remove it.

For users that want it to persist, I'd tell them to explicitly configure it in labels, e.g.:

databases:
  db1:
    dsn: sqlite://
    connect-sql:
      - PRAGMA application_id = 123
      - PRAGMA auto_vacuum = 1
    labels:
      region: us1
      app: app1
      database: db1 # this line is new

If you were worried about breaking existing configs, maybe accept the label value being empty as a sign to remove it:

databases:
  db1:
    dsn: sqlite://
    connect-sql:
      - PRAGMA application_id = 123
      - PRAGMA auto_vacuum = 1
    labels:
      region: us1
      app: app1
      database: # new line, empty value => remove the label in the output metric

Expected result:

queries_total{app="app1",query="query1",region="us1",status="success"} 50.0

@lchopfpt
Copy link

I do not consider the db label useless, but having the ability to not include it could be nice for those that don't want it. Though I can't think of many exporters that allow for finagling which labels are included/excluded.

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

No branches or pull requests

3 participants