How does one query count of a metric on Datadog grouped by tag values?
Let's say the metric orders
has tags category
and status
and we need to get the count of failed orders grouped by the category
tag and display it in a table / top list dashboard widget as follows:
category | failures |
---|---|
apparel | 20 |
gadgets | 24 |
The query that I have tried just sums all the failed orders up (for all categories):
sum:orders{status:failed}.as_count()
On going through the Datadog aggregation methods and space aggregation documents, it can be seen that they support group by aggregation in the queries for metrics.
In this case aggregation can be achieved with sum by
in the following way:
sum:orders{status:failed} by{category}.as_count()
One can refer the Datadog nested queries multilayer space aggregation for more examples.