6

I would like to have a bar graph in graphite/grafana that has a single bar per day, over the week. Ideally we would have the days of the week (Monday,Tuesday...etc) on the x axis labels, and then seven bars in the graph, one for each day of the week. I can't seem to change the X axis at all though.

Thoughts: I could cook the time data, and send it a fixed time since epoch value, but this results in a very thin bar on the grafana page. I could write a script to send a huge amount of metrics with seconds since epoch values representing the entire day in order to make the semblance of a daily bar, but that still doesn't help me change x-axis labels and seems like a horrible way to use this tool.

Can this even be done with graphite, or is it strictly focused on real time graphs?

user3037691
  • 135
  • 1
  • 3
  • 9

1 Answers1

6

Try using the Graphite summarize() function. In Grafana you can find it under the "transform" functions when adding a Graphite metric. Use "1d" for aggregating by day.

Then go to "Display Styles" and check only the "Bars" checkbox to get the bar plot.

This won't give you nice Mo-Su labels in the X axis though.

dukebody
  • 7,025
  • 3
  • 36
  • 61
  • Wow, thanks for this answer! However, summarize is adding up all my values over the course of the day. I have a gauge sending a value that is the number of logins that occured today, rather then incrementing some counter. So when it summarizes it seems to add all these values together.... Anyways I think I can figure that out either by changing the way I send the data, or hopefully using a max() function from grafana, Thanks! – user3037691 Feb 05 '15 at 17:47
  • 1
    You can use `summarize('1d', 'avg')` to use averaging as aggregation function with summarize. – dukebody Feb 05 '15 at 17:52
  • Yea, summarize('1d','last') seems to have achieved my purposes, now I appear to be having a subtle timezone bug somewhere along my server>statsd>graphite pipeline. – user3037691 Feb 05 '15 at 18:27
  • 2
    Is there a solution to this 5 years on that you know of @dukebody or @user3037691? I've got a Postgres table containing a few fields, one of which is a DATE type of the form YYYY-MM-DD. I'd like to show a Grafana Bar Graph where the X-axis is labeled by day-date. Right now, Grafana is showing time and date on X even though no times exist in the data it's ingesting, just dates. Thanks. –  Apr 02 '20 at 04:33