New announcements for Serverless, Network, RUM, and more from Dash!

Counts

Overview

Counters are used to count things.

Submission

Agent check

MethodOverview
self.increment()
deprecated
Used to modify a count of events identified by the metric key string:
  • Can be called multiple times during a check’s execution.
  • Stored as a RATE type in the Datadog web application. Each value in the stored timeseries is a delta of the counter’s value between samples (time-normalized by the aggregation interval which defaults to 1 for Agent checks - so the value is generally the raw count value).
  • Handled by the aggregator Counter class
self.decrement()
deprecated
Used to modify a count of events identified by the metric key string:
  • Can be called multiple times during a check’s execution.
  • Stored as RATE type in the Datadog web application. Each value in the stored timeseries is a delta of the counter’s value between samples (time-normalized by the aggregation interval which defaults to 1 for Agent checks - so the value is generally the raw count value).
  • Handled by the aggregator Counter class
self.monotonic_count(…)Track a raw counter that is ever increasing. Don’t normalize the values to a rate, or calculate the deltas before submitting, as the method does it for you. Samples that have a lower value than the previous sample are ignored (it usually means that the underlying raw counter has been reset):
  • Can be called multiple times during a check’s execution.
    Example: Submitting samples 2, 3, 6, 7 sends 5 (i.e. 7-2) during the first check execution; then, submitting samples 10, 11 on the same monotonic_count sends 4 (i.e. 11-7) during the second check execution.
  • Stored as a COUNT type in Datadog. Each value in the stored timeseries is a delta of the counter’s value between samples (not time-normalized).
self.count(…)Submit the number of events that occurred during the check interval:
  • Can be called multiple times during a check’s execution, each sample being added to the value that is sent.
  • Stored as a COUNT type in Datadog.

DogStatsD

MethodOverview
dog.increment(…)Used to increment a counter of events:
  • Stored as a RATE type in the Datadog web application. Each value in the stored timeseries is a time-normalized delta of the counter’s value over that StatsD flush period.
dog.decrement(…)Used to decrement a counter of events:
  • Stored as a RATE type in the Datadog web application. Each value in the stored timeseries is a time-normalized delta of the counter’s value over that StatsD flush period.

Example

See the DogStatsD-specific documentation for code examples.

In-app modifiers

  • Effect of as_count():
    • Sets the time aggregator to SUM.
  • Effect of as_rate():
    • Sets the time aggregator to SUM
    • Normalizes the input timeseries values by the query (rollup) interval. For example [1,1,1,1].as_rate() for rollup interval of 20s produces [0.05, 0.05, 0.05, 0.05].
  • The raw metric itself defaults to the time aggregator AVG, so querying the metric without either as_rate() or as_count() becomes nonsensical when time aggregation is applied.
  • Note that on very small intervals when no time-aggregation occurs, there is no normalization, and you get the raw metric value counts.

Further reading