How to display a graphite graph of used memory when you have total memory and free memory

graphitemetrics

My servers send mem_total and mem_free metrics to Graphite, but I'd like to display mem_used on my dashboard. I'm currently solving the problem by doing:

offset(scale(servers.foo.*.mem_free,-1),30823052)

where 30823052k is the total memory.

I'm wondering if there's a way that I can leverage graphite to calculate mem_used from mem_total and mem_free for me, so that I can avoid having to hard-code the amount of total memory in my query?

I have been doing some testing with Grafana lately, and have figured out a partial solution, which is:

A) servers.foo.server1.mem_total (mark invisible)
B) servers.foo.server1.mem_free (mark invisible)
C) diffSeries(#A, #B)

but, this solution only works without wildcards – and I really really want to be able to use wildcards rather than having to do this kind of thing for every single server.

I was looking at the available functions, and groupByNode seems like it might be a part of the solution I'm looking for, but I haven't figured out a way to do what I want with it yet.

Best Answer

You can do so using mapSeries and reduceSeries.

reduceSeries(mapSeries(servers.foo.*.*,2),"diffSeries",3,"mem_total","mem_free")
Related Topic