Reputation: 12215
I would like to display the total duration in seconds from the beginning of the range to the end.
The graph would have the total duration in seconds as Y axis and the time as X axis.
It would start from 0s to 3600s for a range of one hour.
I manage to graph it based on a Graphite series however it is not correct when the range is too wide. I guess it is related to the cleaning of the data after some time.
Upvotes: 3
Views: 1049
Reputation: 221
Graphite includes a function called timeFunction which just returns the timestamp for every point in the graph, at an interval you choose. Combined with the offsetToZero function, you can draw a line that counts up in standard time increments and starts at 0 regardless of the duration of the graph. It looks like this:
offsetToZero(timeFunction('duration', 60))
I tested this up to 90 days and at various maxdataPoint values and it seems to work fine. 60s is the default interval for timeFunction, but you can use whatever you like depending on what you think would be a good interval for your dashboard.
If you have a different version of Graphite and you still see the values look strange at different zoom levels, try adding consolidateBy(max) to make sure that if the data points are being consolidated, the highest value is used instead of the average. You might also consolidateBy(min) - Graphite datapoints represent the following period of time instead of the previous, so the first datapoint might be mathematically more correct, depending on your implementation.
(NB: Consolidation of datapoints happens because Grafana sends a maxDataPoints value with its requests to Grafana so that Graphite doesn't return more datapoints that the graph can display.)
Upvotes: 4