How to change the x axis in Graphite/Grafana (to graph by day)?

17,029

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.

Share:
17,029
user3037691
Author by

user3037691

Updated on June 12, 2022

Comments

  • user3037691
    user3037691 almost 2 years

    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
    user3037691 about 9 years
    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!
  • dukebody
    dukebody about 9 years
    You can use summarize('1d', 'avg') to use averaging as aggregation function with summarize.
  • user3037691
    user3037691 about 9 years
    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.
  • Admin
    Admin about 4 years
    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.