sam boosalis
sam boosalis

Reputation: 1977

Graphite: append a "current time" point to the end of a series

I have a "succeeded" metric that is just the timestamp. I want to see the time between successive successes (this is how long the data is stale for). I have

derivative(Success)

but I also want to know how long between the last success time and the current time. since derivative transforms xs[n] to xs[n+1] - xs[n], the "last" delta doesn't exist. How can I do this? Something like:

derivative(append(Success, now()))

I don't see any graphite functions for appending series, and I don't see any user-defined graphite functions.

The general problem is to be alerted when the data is stale, via graphite monitoring. There may be a better solution than the one I'm thinking about.

Upvotes: 0

Views: 1227

Answers (1)

hobbs
hobbs

Reputation: 239682

identity is a function whose value at any given time is the timestamp of that time.

keepLastValue is a function that takes a series and replicates data points forward over gaps in the data.

So then diffSeries(identity("now"), keepLastValue(Success)) will be a "sawtooth" series that climbs steadily while Success isn't updated, and jumps down to zero (or close to it — there might be some time skew) every time Success has a data point. If you use graphite monitoring to get the current value of that expression and compare it to some threshold, it will probably do what you want.

Upvotes: 4

Related Questions