I have a running instance of pushgateway and prometheus. And prometheus is configured to scrape from pushgateway. I am able to push metrics from my .NET applications to pushgateway which are successfully scraped by my prometheus. But when a two similar metrics are pushed to pushgateway, they are considered as one by the prometheus and the count is always displayed as one. Is there a way to increment the prometheus count value when similar metrics are present in the pushgateway.
Pushgateway is not designed to handle this situation. As the official doc said, Usually, the only valid use case for the Pushgateway is for capturing the outcome of a service-level batch job.
https://prometheus.io/docs/practices/pushing/#should-i-be-using-the-pushgateway
Or you can use this instead, which is a aggregating push gateway for Prometheus: https://github.com/weaveworks/prom-aggregation-gateway
The metrics from the two apps should be separated by adding a label that will distinguish between them. This should solve your issue. Note that the pushgateway docs explicitly state that there should be no duplicate metrics.
As @ImPeratOR_ mentioned, prom aggregation gateway is a solid alternative to Pushgateway but I ran into a couple of issues with it such as they additively combines gauges(idk why) and there's no TTL on metrics.
I created and use Metrics Accumulator instead.
- handles counters and gauges. Counters are additively combined and the gauges are last one in are saved unless you use a special label.
- Has partitions for your metrics known as metric groups
- TTL on metric groups.
- HTTP Service discovery mechanism
Both can be deployed as a standalone service.
For full transparency I'm the creator of Metrics Accumulator.
© 2022 - 2025 — McMap. All rights reserved.