23

There does not seem to be a way to replace no data by zeros when using formulas in datadog. I've tried fill zero but it doesn't seem to work I would simply like my dd agent monitor to display 0 instead of no data when it is down

PhilipGarnero
  • 2,399
  • 4
  • 17
  • 24

4 Answers4

30

how about the "default" function?

so default(sum:foo.bar{hello:world} by {baz}, 0) or some such?

stephenlechner
  • 1,836
  • 11
  • 11
25

The default_zero() function does what you're looking for. You can type it in manually, as stephenlechner suggests.

There's another way I found:

  1. Click "Advanced" in the bottom right:

  2. Enter default(a, 0) as the formula, and disable the visibility of metric a:

When you save the graph and reopen, you'll see that things have been reshuffled a little, and you'll see a "default 0" section tagged onto the end of the metric's definition.

Alexander
  • 59,041
  • 12
  • 98
  • 151
8

There is now a default_zero() function that can be used in Datadog by modifying through JSON directly.

user1655072
  • 572
  • 2
  • 10
  • 20
4

It's possible to solve this by to changing the query by using zero interpolation. You can put ".fill(zero)" behind your query in the json or choose the option from the UI. enter image description here

EDIT:

You're right, the interpolation is not working when no data is available. I had the same problem in the end. Support of Datadog said it isn't possible to show zero when there is no data for a metric. Now there is a feature request made for it. It would be nice if more people will request for this feature, so it will be prioritized.

Nonetheless I have tried to create a workaround by adding a second metric that always has data as a second query and added a formula ((b - b) + a) that negates the second query, but when there is data in the intended query it's show in the graph. This will result in a zero line when there is no data available.

Scenario without data: GraphWithNoData

The only problem is that when you have a data in the intended query, it looks ugly and the zero line is gone. As you see in the following screenshot.

Scenario with data: GraphWithData

Conclusion: The workaround is not perfect, but it will work for some situation. For example, filling up query values with zero instead of (no data). I hope this is a bit better answer to the problem.

RobertvBraam
  • 120
  • 2
  • 10
  • it seems not working with only in the doc ( https://docs.datadoghq.com/graphing/faq/interpolation-the-fill-modifier-explained/) It say "Interpolation is not needed, when you graph 1 metric submitted from 1 source: avg:net.bytes_rcvd{host:a} (we assume this host submits this metric always with the same tag list)." – Bruno Adelé Nov 14 '18 at 15:37