Skip to content

Instantly share code, notes, and snippets.

@alq666
Created July 25, 2012 02:50
Show Gist options
  • Save alq666/3174101 to your computer and use it in GitHub Desktop.
Save alq666/3174101 to your computer and use it in GitHub Desktop.
Datadog functions

A short introduction to Datadog functions

You can apply functions to metric queries in the graph editor, as long as you use the JSON editor.

The general format is:

function(metric{scope} [by {filter}])

In case of binary operators (+, -, /, *), the format is:

metric{scope} [by {filter}] operator metric{scope} [by {filter}]

The filter part is optional.

Simple arithmetic

  • query + query
  • query - query
  • query * query
  • query / query

Derivation and integration

  • dt(query): time delta between points
  • diff(query): value delta between points
  • derivative(query): 1st order derivative, diff / dt
  • integral(query): sum(value * dt)
  • cumsum(query): sum(value)
  • rate(query): 1st order derivate that skips non-monotonically increasing values

Some syntactic sugar:

  • derived(query): synonym for derivative
  • per_second(query): synonym for rate
  • per_minute(query): 60 * rate
  • per_hour(query): 3600 * rate

Moving Averages

  • avg_5min(query): average over past 5 minutes
  • avg_10min(query): ditto for 10 minutes
  • avg_30min(query): ...
  • avg_hourly(query): ...
  • avg_daily(query): ...

Exponentially-weighted averages using variable decay

(from pandas)

  • ewma_1(query): decay = 1, same as average
  • ewma_3(query): decay = 1/2
  • ewma_5(query): decay = 1/3
  • ewma_10(query): decay = 2/11
  • ewma_20(query): decay = 2/21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment