7

How can I summarize graphite data depending on the selected interval? If the selected interval is up to 1 hour, the data counter should show data points for every minute. If the interval is up to 3 hours, the data should be summarized over 5 minutes. If the interval is up to 1 day, the data should be summarized over 15 minutes.

Is this possible?

Joyce Babu
  • 19,602
  • 13
  • 62
  • 97

2 Answers2

8

You can get something close this this using by creating an interval template variable, enable the Auto option, and set number of steps. In the example below it's set to 40 steps so it will pick an appropriate interval based on the time range.

enter image description here

Use the variable like this: enter image description here

blak3r
  • 16,066
  • 16
  • 78
  • 98
3

AFAIK Graphite doesn't do this automatically.

However since Graphite has a public API you can script this yourself automatically to retrieve the graph with the correct summarizing period. Grafana for example does this when using the 'auto' option for interval template.

Pseudo-code:

if interval == '1h':
    get_metric(summarize(metric, '1min', 'sum')
elif interval == '3h':
    get_metric(summarize(metric, '5min', 'sum')
elif interval == '1d':
    get_metric(summarize(metric, '15min', 'sum')
dukebody
  • 7,025
  • 3
  • 36
  • 61
  • Templating was exactly what I was looking for. Thank you for pointing me in the right direction. – Joyce Babu Nov 27 '14 at 18:34
  • 3
    It's odd to me that Graphana doesn't do this automatically. When I show the last hour I get all my data events (I believe), but when I show the last 7 days I see one point for each hour with the value of a single metric in that range, not the sum. Is there a way to use `summarize` but have it apply whatever range Graphana is using in the display? – jwadsack Oct 08 '15 at 20:38