smc
smc

Reputation: 730

What is the right metric type if I want to emit number of results of a query, as datadog metric?

My daemon keeps querying db on a cronly basis. In every iteration, (a) the deamon makes a DB query (b) receives some documents from db (c) processes those results. I want to emit the number of documents returned for the query on Datadog. What is the right metric type?

Upvotes: 1

Views: 5406

Answers (2)

Jeffrey Harmon
Jeffrey Harmon

Reputation: 2437

The best metric type would be a histogram metric. This will take multiple values, and pre-aggregate them within a flush window, so you will be able to get things like min/max/sum/avg and various percentiles.

If you run multiple times within a flush window:

  • count would combine multiple values together, so you would lose the individual numbers, meaning you couldn't easily tell between the process returning a lot of documents, or it returning only a few, but being called a lot
  • gauge, as mentioned in @narayan's answer, would only keep the latest, making it harder to get thins like the max/min count.

Upvotes: 2

narayan
narayan

Reputation: 1149

Gauge metric types will do the job here given that your query does not run more than once within 10 seconds. If that is not the case, go for count metric

The flush interval in datadog by default is 10 seconds, if you use a gauge metric and the metric is reported more than once in a flush interval, datadog agent only sends the last value ignoring the previous ones. For count metric in contrast, the agent sums up all the values reported in the flush interval.

More details about flush interval here.

Upvotes: 4

Related Questions