Reputation: 2327
I don't understand the difference between events and metrics in DataDog. I'm trying to create a count indicator in my dashboard so I can now how many times some type of event has happened.
There is a lot of events named some.event.name
, but no matter what query I use, it always returns 1
.
I've tried with this queries,
sum:some.event.name{*}
count_nonzero(sum:some.event.name{*})
count_not_null(sum:some.event.name{*})
I've also tried with other aggregation functions avg|max|min|sum
and allways the result is 1
.
Any help will be highly appreaciated.
Upvotes: 9
Views: 7455
Reputation: 66
In Ruby on the client, I use:
Datadog::Statsd.new(hostname, port)
datadog.increment(metric_name, tags: tag_list)
I then have a dashboard with a Query Value widget, set to "take the [Sum] value from the displayed timeframe".
sum:some.event.name{*}.as_count()
I tested this and it seems to give the right numbers. The .as_count() seems key.
Upvotes: 0
Reputation: 2327
Well I realized that the query value only works with metrics, so to create a counter we can emit metrics with value: 1
and then count them with the rollup(sum, 60)
function.
dog.emit_point('some.event.name', 1)
sum:some.event.name{*}.rollup(sum, 60)
The main thing to understand here is that DataDog does not retrieve all the points for a given timeframe. Actually as McCloud says, for a given time range we do not return more than 350 points, which is very important to have in mind when you create a counter.
When you query value from a metric in a timeframe, DataDog return a group of points that represents the real stored points, not all the points; the level of how those points are represented (as I understand) is called granurallity, and what you do with this rollup
function is to define how those points are going to represent the real points, which in this case is going to be using the sum
function.
I hope this helps somebody, I'm still learning about it. Regards
Upvotes: 5
Reputation: 2721
The free text editor you have in the screenshot is for metric queries. Events in graphs are added as overlay to show when events happened over time.
There is no widget, as of now, that shows a single value for the number of times an event occurred. But you can use the event timeline widget, which will show a timeline of events grouped by status and bucketed over a defined period of time. See below:
Upvotes: 0