Is there a way to force the output of a Stat panel in Grafana to only show values in days

Note: This is also found on StackOverflow. Since I can’t post more than two links, please refer to that to see what documentation I actually looked at, etc.

I’m building a Grafana dashboard with some Stat panels that show average, minimum, and maximum time values (see below) for specific fields in my database. I’m storing the data in seconds and setting the value’s units to seconds after which the panel displays the time in weeks, days, hours, etc. For the sake of consistency, I would like everything to be shown in days but I haven’t been able to find a way to force units for the output value. If it’s possible to do this, could someone please point me to some docs, or something that could show me which configurations to make in my panels?

sample panels

So far, I’ve tried (without success):

  1. Configure each panel to use units of days
    • The result of this was that everything showed up in years, etc.
  2. Configure each panel to create a new field by performing a binary calculation where I converted from seconds to days and then I updated the units to be days
    • The result was that the values were not changed at all -> instead of showing X days, or whatever, it just showed the value in seconds without the units. I’m not sure what I messed up there, but it didn’t change anything.
  3. I found this link that discusses setting a time range for queries
    • This didn’t end up being useful for what I was trying to do because it was actually geared towards changing the query to a specific date range rather than the output.
  4. I looked through the transformations documentation, stat panel documentation, and a few other panel documentation pages in an effort to see if there was any information on how to do it but I was unable to find anything on forcing the output value to use a specific unit.

Update:

I believe I found a good-enough solution but not one where I can include the units with the values (see below).

updated version

Please see StackOverflow question referenced above for more detailed update.

1 Like