Memory gauge using FREE and TOTAL values

  • What Grafana version and what operating system are you using?
    8.4

  • What are you trying to achieve?
    Show a gauge display with Free memory and gauge max set to Total memory

  • How are you trying to achieve it?
    Loki query and Grafana gauge

  • What happened?
    Can not get the gauge max to be total memory.

Hi, I’m trying to show a gauge of the memory usage of a system based on a Loki query, which returns fields “Free” and “Total”. The gauge max needs to be set to the Total memory, and the gauge value needs to be the Free memory.
Since there are dozens of systems with different memory configurations, I do not want to hard code the max. Also I know I can do % free (free*100/total) gauge but I would rather show the absolute values (GiB).
How do I configure a query and gauge to show this?

Here is my current Loki query:
last_over_time({site="SiteA",system="System1",itemtype="OS",logtype="WMIC"} | json Free="WMIC.os.FreeVirtualMemory", Total="WMIC.os.TotalVirtualMemorySize", Name="WMIC.os.CSName" | unwrap Free[10m]) by (Name) / 1048576

(Grouping by Name is a bit of a red herring since the selector returns only one system and thus only one Name. This can be changed, its not a requirement of the gauge to show the system name)

Thanks

welcome to the :grafana: community @blyefd!

There’s an interesting thread in github regarding query transforms where someone is trying to accomplish something similar and got some suggestions. Here’s a link to the comment in the discussion: