integrations-core icon indicating copy to clipboard operation
integrations-core copied to clipboard

Agent v6: prometheus summary counts are not sent as monotonic counters

Open martin-sucha opened this issue 7 years ago • 16 comments

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:

  1. Add a summary metric to your prometheus endpoint
  2. Set the agent to scrape it
  3. Observe that the value is always increasing

Describe the results you received:

Screenshot from 2019-06-12 16-56-31

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

martin-sucha avatar Jun 12 '19 15:06 martin-sucha

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

DylanLovesCoffee avatar Jun 27 '19 14:06 DylanLovesCoffee

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.

stale[bot] avatar Jul 27 '19 15:07 stale[bot]

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!

DylanLovesCoffee avatar Jul 31 '19 20:07 DylanLovesCoffee

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.

stale[bot] avatar Aug 30 '19 20:08 stale[bot]

Where is the monotonic_diff function? I don't see it image

tonglil avatar Sep 05 '19 19:09 tonglil

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).

tonglil avatar Sep 05 '19 20:09 tonglil

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.

stale[bot] avatar Oct 05 '19 20:10 stale[bot]

Seems to still be an issue.

tonglil avatar Oct 05 '19 21:10 tonglil

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.

stale[bot] avatar Nov 28 '19 21:11 stale[bot]

Not stale

jaygorrell avatar Jan 12 '20 01:01 jaygorrell

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

ofek avatar Jan 12 '20 13:01 ofek

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,
                )

sirianni avatar Mar 17 '20 19:03 sirianni

I agree, I don't know why this issue is so hard for them to grasp..

tonglil avatar Mar 17 '20 23:03 tonglil

You're correct, histogram sums should be handled consistently with counts. We'll reopen this to track.

mikezvi avatar Mar 23 '20 23:03 mikezvi

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:

  1. Verify that you can still reproduce the issue in the latest version of the integration.
  2. Comment that the issue is still reproducible and include updated details if possible.

Thank you for participating in the Datadog open source community!

stale[bot] avatar Apr 23 '20 04:04 stale[bot]

Closing as https://github.com/DataDog/integrations-core/pull/6127 introduces a flag to submit _sum metrics as monotonic counts.

ChristineTChen avatar Jul 09 '20 15:07 ChristineTChen