Inverting a percentage chart

I’m collecting several stats (through collectd) which show idle/free %ages. I’d like to convert these to busy/used by subtracting the values from 100. I can’t work out how to do this.

Grafana 5.0 (latest as of last night)

Hi,

If you’re using graphite as datasource you can use the offset function or scale function.

Marcus

Rats! I’m using influx (it seems to offer a simple interface with a small footprint). I take it, then that it’s not possible.

Thanks for the responses.

Graham

Hi,

Sorry I just took for granted graphite since you’re using collectd :slight_smile: Seems like influxdb has some support mathematical operators, but haven’t used them myself.

Marcus

I know this is a year old, but since I found the post while searching for a very similar answer I wanted to share the “fix” I’ve been using for this.

Just add a math() operator to the InfluxDB query in question with * -1 + 100 as the content, like this:

math(* -1 + 100)

Since a lot of data I get from Telegraf, JMX sources, and elsewhere ends up being in “pecent used” versus “percent free” (or vice versa) this has helped me keep dashboards consistent.

2 Likes

Hello fivesixzero,

This is working great but could you explain the logic behind this math ? Because since is it math it should be logical but I don’t get it :wink:

Thanks

  • means multiply
    -1 is minus one
    +100 means add one hundred

So, “multiply by minus one and add one hundred”.

Read it the other way round if you like: “add to one hundred the value
multiplied by minus one”.

Oh, what is “add the value multiplied by minus one”?

Ah, of course - it’s “subtract the value”.

So, “subtract the value from one hundred”.

That’s how to get “percent used” instead of “percent free” and vice versa :slight_smile:

Antony.

Thanks I kew it was easy, I though that the influx value was replace by the * but it did not make any sense now it make sense !

Ciao