Agent v6: prometheus summary counts are not sent as monotonic counters
Prometheus check does not send the .count metric generated from summary as deltas, but the raw value is sent. A similar issue was solved for counters with send_monotonic_counter option, but send_monotonic_counter does not have any effect on counters which are part of summary metrics.
Steps to reproduce the issue:
- Add a summary metric to your prometheus endpoint
- Set the agent to scrape it
- Observe that the value is always increasing
Describe the results you received:

A sloped line can be seen in this graph
Describe the results you expected:
Datadog agent should send deltas and and a (more or less) flat line should be visible. It should either respect send_monotonic_counter setting or a newly introduced similar setting (for backward compatibility).
Additional information you deem important (e.g. issue happens only occasionally):
This issue is related to https://github.com/DataDog/integrations-core/issues/1303 where send_monotonic_counter was introduced and is probably also related to https://github.com/DataDog/integrations-core/issues/1303#issuecomment-496142520
Hey @martin-sucha - thanks for raising the issue. For the time being, we've created a card internally to track this until it can be reviewed by our team. If you would like to keep track of it as well via a support ticket, feel free to open one up and reference this issue.
-Dylan
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
Hey @martin-sucha, I wanted to follow up on getting a monotonic count for a gauge metric here (if a ticket hasn't already been opened) since there's a monotonic_diff() function available in-app that might help. This is under the assumption that you currently have send_monotonic_counter: false configured in the relevant check to report your counts as gauges.
The monotonic_diff() function acts similarly to the diff() function but is monotonic, so it should give you a fairly accurate delta between values. At the moment, you'll also need to disable interpolation using .fill(last) so that we do not report the delta of the interpolated points, which would lead to much smaller values (we will look into doing this implicitly when monotonic_diff() is used). On top of that, you can aggregate points over time by max rather than the default of avg using .rollup_max().
So a query for an arbitrary gauge metric would look like the following and should report the deltas you're looking for: monotonic_diff(<gauge_metric>{*}.fill(last).rollup(max)). Feel free to send us a note if you have questions!
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
Where is the monotonic_diff function? I don't see it

I agree with @martin-sucha that counters (and sums) collected form summaries metrics should also be sent as monotonic counters, instead of defaulting to the gauge metric type in Datadog upon ingestion.
This should be true with the send_monotonic_counter: true option because when metrics get scraped, I want both counters and summary counts to be monotonic, so it is not possible to set that option to false (which is the requirement for the solution posted above).
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
Seems to still be an issue.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.
Not stale
Hey all! Sorry for the lapse in communication, but this is now possible with send_distribution_counts_as_monotonic https://github.com/DataDog/integrations-core/pull/4629
Shouldn't the histograms _sum also be sent as a monotonic counter? It's currently hardcoded to send as a gauge. This makes it impossible to divide the _sum by the _count in order to get an average for the distribution (which seems to be the point of sending the sum & count).
https://github.com/DataDog/integrations-core/blob/master/datadog_checks_base/datadog_checks/base/checks/openmetrics/mixins.py#L706-L713
if sample[self.SAMPLE_NAME].endswith("_sum"):
tags = self._metric_tags(metric_name, val, sample, scraper_config, hostname=custom_hostname)
self.gauge(
"{}.{}.sum".format(scraper_config['namespace'], metric_name),
val,
tags=tags,
hostname=custom_hostname,
)
I agree, I don't know why this issue is so hard for them to grasp..
You're correct, histogram sums should be handled consistently with counts. We'll reopen this to track.
This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that this will not be automatically closed, but the notification will remind us to investigate why there's been inactivity.
If you would like this issue to remain open:
- Verify that you can still reproduce the issue in the latest version of the integration.
- Comment that the issue is still reproducible and include updated details if possible.
Thank you for participating in the Datadog open source community!
Closing as https://github.com/DataDog/integrations-core/pull/6127 introduces a flag to submit _sum metrics as monotonic counts.