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
4 Answers
how about the "default" function?
so default(sum:foo.bar{hello:world} by {baz}, 0)
or some such?

- 1,836
- 11
- 11
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:
Click "Advanced" in the bottom right:
Enter
default(a, 0)
as the formula, and disable the visibility of metrica
:
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.


- 59,041
- 12
- 98
- 151
-
2I don't have the advanced button.... – Mark Sep 29 '22 at 10:15
There is now a default_zero() function that can be used in Datadog by modifying through JSON directly.

- 572
- 2
- 10
- 20
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.
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.
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.
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.

- 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