-
Notifications
You must be signed in to change notification settings - Fork 801
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
Allow adding arbitrary labels to metrics when generating output #741
base: master
Are you sure you want to change the base?
Conversation
It's useful to be able to apply a label across all metrics, for example when using a multi-processing framework to apply a label for worker ID to all metrics (including from builtin collector types). This change adds a new Registry type that applies a dictionary of labels when metrics are collected. Signed-off-by: Will Newton <[email protected]>
Signed-off-by: Will Newton <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, so this is a bit backwards of what I was imagining, I apologize for not being clear in the other comment/misunderstanding your goal. The use case I would support is what is described in client_golang/prometheus#WrapRegistererWith. This allows systems such as distinct workers to register the same set of metrics with a distinct label, but would not apply to every metric being exported. For more details on why we don't encourage labels on every metric see https://prometheus.io/docs/instrumenting/writing_exporters/#target-labels-not-static-scraped-labels.
Does that make sense/would it help your use case?
samples with additional labels given in the dictionary. | ||
|
||
Intended usage is: | ||
generate_latest(REGISTRY.labelled_registry(['a_timeseries'])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This example is incorrect as it should be passing a dict of constant labels.
@csmarchbanks I'm a little confused by your comment, since the Python client doesn't seem to have the concept of a |
I can imagine a few implementations that would be acceptable, but my guess is that we will have a new class that inherits from
to add all of the labeled metrics to the default registry or any other registry. Does that make sense? I might even be ok with just adding a const_labels variable when initializing a CollectorRegistry, but not sure if that would be best compared to a new class. |
It's useful to be able to apply a label across all metrics, for
example when using a multi-processing framework to apply a
label for worker ID to all metrics (including from builtin
collector types). This change adds a new Registry type that
applies a dictionary of labels when metrics are collected.
Signed-off-by: Will Newton [email protected]