Responding with default values in custom numeric metrics with Datadog


#1

The Question

I have a use case where I want to report all HTTP 500 events when they occur as integer counts, but also send a default value of 0 if no 500 event occurred during a request.

How can I achieve this with the Datadog adapter?

Things I’ve Tried

As a first pass, I attempted to create a rule that has match: true, and then a metric that, for value, sets it to read conditional(response.code.startsWith("5"), "1", "0").

I then told the rule to use the Datadog adaptor, and registered this metric with said adaptor in the rule.

This threw errors in the mixer logs, likely because request.code is an integer and startsWith is probably a function that expects a string - we lost all metrics as a consequence.