Is there any way to fill in missing data in graphite when using statsD?
Asked Answered
M

4

16

I'm using statsD to report counter data to graphite; sends a tick everytime I get a message. This works great, except in the situation when statsD has to restart for whatever reason. Then I get huge holes in my graphs, since statsD is now no longer sending '0' every 10 seconds for periods when I didn't get any messages.

I'm reporting for various different message types and queues, and sometimes I don't get a message for a particular queue for a long time.

Is there any existing way to 'fill-in' the missing data with a default value I specify (in my case this would be 0)?

I thought about sending a '0' count for a given metric so that statsD starts sending 0's for it, but I don't always know the set of metrics I'll be reporting in advance.

Monjan answered 6/12, 2012 at 4:19 Comment(1)
Turns out there is a function that will do exactly what I want. Although as @ALQ points out, it's important to know that it would affect aggregates; transformNull().Monjan
M
9

If you just want to "fill in" the visual graph with zeros, look at "Graph Options -> Line Mode -> Draw Null as Zero". This won't let you set a value other than 0, and it won't cause 0's to show up if you get the data in json or csv format, but it's often what you want if you just want to see a graph with some stretches where no data gets recorded.

without Draw Null as Zero

With Draw Null as Zero

Meghanmeghann answered 12/12, 2012 at 8:24 Comment(0)
C
19

Check out the function transformNull that Graphite provides. e.g.

transformNull(stats.timers.deploys.all.duration.total.mean, 0)

This will map sections with null data to 0.

Cumming answered 28/6, 2013 at 3:45 Comment(0)
S
12

You can use the "keepLastValue(requestContext, seriesList)" function in graphite to deal with missing data. It "[c]ontinues the line with the last received value when gaps (‘None’ values) appear in your data, rather than breaking your line."

Strut answered 6/12, 2012 at 4:57 Comment(2)
That's excellent! Not quite what I want, since I want to be able to report 0 rather than the last value. However, more often than not, the value is 0 so this will work for the moment. Thanks!Monjan
Not to be pedantic, sending 0 instead of "no data" will have a lowering effect on your aggregates (quantiles, average).Bull
M
9

If you just want to "fill in" the visual graph with zeros, look at "Graph Options -> Line Mode -> Draw Null as Zero". This won't let you set a value other than 0, and it won't cause 0's to show up if you get the data in json or csv format, but it's often what you want if you just want to see a graph with some stretches where no data gets recorded.

without Draw Null as Zero

With Draw Null as Zero

Meghanmeghann answered 12/12, 2012 at 8:24 Comment(0)
T
2

The solution to this problem is not to keep the last value or transform nulls. Implementing one of those options will only cause you to display incorrect data, and you will not be alerted when something is wrong.

You need to change your storage schema so that it stores the amount of data that you're sending, and no more.

If metrics are being sent every 5s and your storage schema says 1s, you will get five data points, four of which will be null.

Check out this doc: https://github.com/etsy/statsd/blob/master/docs/graphite.md

Tamp answered 13/5, 2016 at 18:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.