Grafana Axes Custom Units

This forum was archived to /woltlab and is now in read-only mode.
  • Hi,

    I am using a custom check script that returns 4 diffrent states. (0 = OK, 1 = Warn, 2 = Crit, 3 = Unknown)

    Icinga2 stores this data in an influxdb DB and I want to use Grafana to display the data.

    My first thought was to customize the Y axis Units, so instead of the numbers 0 - 3 it would show the associated states.

    But this seems to be not possible.

    My second thought is to create multiple queries that each return only one state and name these queries to the associated states.

    But I cant find out how to create a query that only searches for one specific value.

    SELECT min("state") FROM "check_myscript" WHERE "hostname" = 'myHost' AND "service" = 'myService' AND $timeFilter GROUP BY time($__interval)

    In this query I am searching for the minimal value in the field state. But I want to search for the value 3.

    If anybody knows how to do this, or has another solution, please share it with me.



  • Well what you could do is visualize as Graph and set thresholds (found to the left under the Display Tab when editing your metric) and call those thresholds accordingly. This gives you lines within the graph representing those levels that you can even use for alerting via Grafana or at least alert lists as an overview should you have more of those graphs.

    My question would be if you need the history (the time interval) or just the state the service has now. If you need the later why not pull the state (without the min) that it has just now and display that in a singlestat panel. With value to text mapping you can easily represent what you want, with color thresholds you can even fill background or text however you see fit for the task. With sparklines on you'd even see if there was a state change recently (at least with Graphite as a datasource you do but i think that should be true for InfluxDB also).

    Maybe i missunderstood what you want to represent (as the time interval and the min operator in front of the value confuses me in the context of service metadata), if so please go in more detail and we go from there.

  • Yes, I need the history of the check. But the thresholds work fine, thanks.

    Now its just that the critical state is on top of the graph, because its the return code 3 of the script, and the ok state in on the bottom.

    Thats looks of course not that nice, but I may just change the output of the script.

  • Yes either do that or at lest what i can think of to mak it look "nicer" or better more readable is set Y-min to -1 and Y.max to 4 so you have a bit of room above and below makint it more readable. What might also be a good idea is to set the treshold to 2,7 or something that the graph really visally clears the treshold line and set said threshold line to not fill the space below with its color.

    But that's jsut my two cent, cool thing that it works for now!