Reputation: 9439
What happens if the help text for a metric changes, i.e. between deploys?
Here is some example output which I got from /api/v1/targets/metadata
. It shows two instances with the same metric name my-counter
, but different help texts.
First instance:
"target": {
"instance": "instance-1:6000",
"job": "app"
},
"metric": "my-counter",
"type": "counter",
"help": "This counts something"
And the second instance:
"target": {
"instance": "instance-2:6000",
"job": "app"
},
"metric": "my-counter",
"type": "counter",
"help": "This counts the same thing, just different help text"
The Prometheus dashboard/charts don't seem to care. Are there other implications?
I'm asking because in the Go docs for prometheus/client_golang it says:
Descriptors registered with the same registry have to fulfill certain consistency and uniqueness criteria if they share the same fully-qualified name: They must have the same help string and the same label names [...].
Upvotes: 1
Views: 2041
Reputation: 10134
AFAIK the uniqueness constraints only apply within the client. I.e. if you declare two metrics with the same name, they should have the same labels and help text or the client will blow up (as it will have to expose the time series from both those metrics on the same /metrics
page, with a single help string).
Prometheus the server doesn't care about help strings (or even counters vs. gauges, for that matter) beyond the parsing stage. So it will never know that the same metric has different help strings on different targets.
I'm also pretty sure (although don't quote me on this) that Prometheus the server doesn't care about labels for the same metric being the same across multiple instances. Else you wouldn't be able to add a label to an existing metric and do a rolling upgrade of your service without losing data.
In other words, the client tries to be very strict with what it will accept from an application; but the server needs to be very loose in what it will accept from a target. For starters, those target may not even use one of the client libraries (which have differences among them anyway), but instead roll its own /metrics
page from scratch. (Although Prometheus may still not like two metrics with different sets of labels on the same /metrics
page.
Upvotes: 3