Grafana, influxdb and texts

(Otto Brandstaetter) #1


I just defined a check in icinga2, which returns the display text of one of our printers.
This was done using the check_snmp_printer check.
The check returns (besides a return code) a string like “Printer ready”.
This metric does not show up in influx (I do not know why).
I would like to show up the text of the last check in grafana, but I do not have any idea how to implement this. Maybe anyone has a hint for this?
Of course I could modify the script to write the current state somewhere (web-server, text-file or something), but I would hope, that this can be done somehow directly with this tools…
Best regards and thanks in advance,


Only performance data is written to influxdb when you enable the InfluxdbWriter. The text your check returns is no performance data. You could modify your check so it adds performance data (e.g. | ‘ready’=1) when the display says “Printer ready”. Then you have something to display in grafana.

(Carsten Köbke) #3

You can also mmodify your influxdb writer object to send a custom variable that is filled with the text from your check. Or you can add also the text taken out from the ido db into grafana :slight_smile:

(Otto Brandstaetter) #4

Thanks for the hints.
Do you think about something like this:

custom_template = {
measurement = "customvar"
tags = {
  hostname = "$$"
  service = "$$"

When exactly would a new entry written to influxdb?
As soon as the customvar changes?
I think I do not really understand the concept yet…

(Carsten Köbke) #5

You want to get your custom variable written to influx with:

tags = {
  hostname = "$$"
  service = "$$"
  blabla = "$service.vars.mycustomvar$"

(Otto Brandstaetter) #6

Thanks a lot!

In the end I thought that connecting to the ido db and selecting out the proper values was the easiest solution for me.
Just in case someone needs this in the future, the select looks something like this:

select concat(trim(trim(output, ','),'.'), ' (', to_char((status_update_time at time zone 'utc'), 'DD.MM.YYYY HH24:MI:SS'), ')') from icinga_servicestatus where servicestatus_id = <yourserviceid>

This results in something like:

Druckbereit (06.12.2018 08:12:47)

(The trim is necessary here as the output of this check ends with a “.” or “,” sometimes…)

Or whatever information you want to be displayed…