-
Notifications
You must be signed in to change notification settings - Fork 446
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
prometheus duplicate metrics #1941
Comments
@jayasai470 thanks for providing the repro steps. |
@jayasai470 - The reason for these duplicates are because Prometheus exporter only support Cumulative temporality. This means, if there are no measurements generated by the application/instrumentation after a particular time, the periodic exporter will keep on exporting the total aggregated requests. As mentioned here - Cumulative temporality means that successive data points repeat the starting timestamp. For example, from start time T0, cumulative data points cover time ranges (T0, T1], (T0, T2], (T0, T3], and so on. |
response from @jayasai470 on slack - I have moved the counter initialization to separate method, thought same counter is retrieved even when I initialize multiple times.
FYI below is our response from nodejs sdk
--> i dont see this value as in Cumulative temporality like you were mentioning in the comments
at any point of time this does not show the duplicated count values and also the numbers are incremented properly. |
@jayasai470 - So I did some tests with Prometheus exporter, and your analysis is correct. With every fetch, the Prometheus exporter should give the cumulative aggregated values from all the configured instruments. And there should be no duplicates. @esigo fyi - I think we shouldn't be using PeriodicMetricReader with PrometheusExporter. With every periodic fetch, the cumulative metrics gets stored in the Collector vector, and old data is not deleted. This vector should only contain latest cumulative data, not all previous data. This can be achieved if we collect metrics only when there is http request to pull the metrics:
And PrometheusExporter should be implemented as PullMetricReader. ( Similar to how JS and Python implements it). Javascript implementation : https://github.com/open-telemetry/opentelemetry-js/blob/2b59c2820c99e7f65012e01b6a310b8438b79e89/experimental/packages/opentelemetry-exporter-prometheus/src/PrometheusExporter.ts#L30 In general, PeriodicMetricReader works good for push model where we push the latest cumulative metrics to the agent, not in the pull model where we have to store these metrics in intermediate storage before they get pulled. |
prometheus metrics endpoint return duplicate metrics and not updating them properly on a SimpleWebServer api endpoints.
Steps to reproduce
Created a sample repo which reproduces this issue. https://github.com/jayasai470/opentelemetry-cpp-sample
What is the expected behavior?
Get metrics without duplicates
What is the actual behavior?
The text was updated successfully, but these errors were encountered: