I would like to propose an option to be added to each metric type, which would allow specifying default label values for that metric only. Those labels would then be applied to each metric value (unless the value is overridden when recorded, similar to how default labels already work at the client level in prom-client).
It would look something like this:
const counter = new client.Counter({
name: 'metric_name',
help: 'metric_help',
labelNames: ['my_label'],
defaultLabels: {
my_label: 'my_value'
}
});
counter.inc(); // recorded with my_label: my_value
counter.inc({ my_label: 'my_other_value' }); // recorded with my_label: my_other_value
If this is a valid use case / not already possible, I would love to contribute.
More use case details:
My team uses prom-client to expose metrics which are scraped by prometheus and ultimately pushed to newrelic via a prometheus remote write integration.
We have an issue occasionally where if a metric is created that does not follow the naming convention expected by newrelic, newrelic interprets the metric as an inappropriate type (most often, counters are interpreted as gauges). I'd like to use this API to add the newrelic_metric_type label in a universal way to prevent this.
I would like to propose an option to be added to each metric type, which would allow specifying default label values for that metric only. Those labels would then be applied to each metric value (unless the value is overridden when recorded, similar to how default labels already work at the client level in
prom-client).It would look something like this:
If this is a valid use case / not already possible, I would love to contribute.
More use case details:
My team uses prom-client to expose metrics which are scraped by prometheus and ultimately pushed to newrelic via a prometheus remote write integration.
We have an issue occasionally where if a metric is created that does not follow the naming convention expected by newrelic, newrelic interprets the metric as an inappropriate type (most often, counters are interpreted as gauges). I'd like to use this API to add the
newrelic_metric_typelabel in a universal way to prevent this.