You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need the ability to use the increase or rate function and see when a metric goes from uninitialized (Which I consider 0) to a non-zero value. According to official docs,
There SHOULD be a way to initialize a given Child with the default value, usually just calling labels(). Metrics without labels MUST always be initialized to avoid problems with missing metrics.
This means, I should be able to specify in advance a metric's labels to set to zero so initial scraping shows that zero value.
There is already a workaround for Counter and Gauge by calling metrics.WithLabels("exampleLabel").Inc(0) substituting in the appropriate labels. There is not a workaround for Histogram that I can find though. This is of course not possible when possible labels are not know in advance, but when they are known in advance, it is very beneficial to be able to specify them.
@jnovick I believe there is functionality to handle your use-case.
If you use MetricFactory to create a metrics there is an option to suppressEmptySamples (which is true by default), try to set it to false while creating the metric. Then the sample should appear in payload once you call WithLabels method. I cannot test the suggestion yet, but I can create a sample for you later.
I need the ability to use the increase or rate function and see when a metric goes from uninitialized (Which I consider 0) to a non-zero value. According to official docs,
This means, I should be able to specify in advance a metric's labels to set to zero so initial scraping shows that zero value.
There is already a workaround for
Counter
andGauge
by callingmetrics.WithLabels("exampleLabel").Inc(0)
substituting in the appropriate labels. There is not a workaround forHistogram
that I can find though. This is of course not possible when possible labels are not know in advance, but when they are known in advance, it is very beneficial to be able to specify them.Similar issue in another Prometheus Library: siimon/prom-client#118
The text was updated successfully, but these errors were encountered: