I’m struggling to properly query and display boolean data in Grafana. My schema may be at fault.
Say I have 50,000 objects, let’s just use servers for an example, and I want to store a boolean value for each server, maybe something like is the server up to date with patches?
So once per day I query the servers and put the data into a measurement called servers that might look like:
tags: { ‘serial’ : ‘x1234’ }
fields: {‘patching_up_to_date’ : true }
I end up with a series for every server, I think this is ok, or at least necessary since I want to GROUP BY serial. Now I want to count the number of servers that are false, using their last known value No problem:
select count("last") from (select last("patching_up_to_date") FROM servers GROUP BY serial) WHERE "last" = false
name: servers
time count
0 2940
What I want to know is the percentage of servers that are false. I can have separate single stats to display the counts of true and false, but Grafana and Influx don’t seem to give me a way to combine these counts to calculate the percentage. What’s the best approach? Is there a complex join I could use to achieve this or do I need to do some SELECT INTO queries and then query against the rolled up metric?