Grafana Dashboard for 2 Server Groups

#1

Hello,

in Icinga2 director i have create 2 Server Groups for example Linux and Windows. And in Grafana I like to create 2 Dashboards. In the first Dashboard are all Linux-Server and in the second are all Windows-Server.

But I have trouble with the InfluxDB Query. I dont see anything with Hostgroups or Service Groups: At the moment I use are Query where the most Servers are matched but not all are in the Group. I made a Query with Service names:

SELECT hostname FROM (SELECT LAST(value),hostname FROM load GROUP BY hostname) WHERE  hostname =~ /[^jdf23.example.net]/

Is there a way to query host groups?

(Proquibas) #2

Hi @pulsar,

To do that, you need to modify your influxdb.conf under the /etc/icinga2/features-enabled and add the data you want to write in influxDB, example of mine:

host_template = {
measurement = “$host.check_command$”
tags = {
hostname = “$host.name$”
system = “$host.vars.system$”
usage = “$host.vars.usage$”
hostgroup = “$host.groups$”
}
}

Then you can query using “hostgroup”, “usage” or “system” in the example above.
Regards.

1 Like
#3

Hello Proquibas,

thank you :slight_smile: Had me, after some search, almost thought that it has something to do with this file. Now I understand it. The Problem is resolved.

#4

Hello again,

I reopen the problem because I have problems with InfluxDB query.
had modify the file how discribed by Proquibas. Can see the hostgroups in the InfluxDB:

icinga@icinga2:~> influx -database icinga2influx -execute 'SHOW TAG VALUES WITH KEY = "hostgroup"'
name: hostalive
key       value
---       -----
hostgroup [ \"Linux_Server_Grp\" ]
hostgroup [ \"Netzwerk_Switche_Grp\" ]
hostgroup [ \"VMware_Grp\" ]
hostgroup [ \"Windows_Server_Grp\" ]
hostgroup [ ]

But my problem is now how is the correct Query to get the hostnames in the Hostgroups?

many Thx

(Carsten Köbke) #5
SHOW TAG VALUES WITH KEY = "hostgroup" WHERE hostgroup = 'Linux_Server_Grp'

more information on how to build queries can be found in the docs

Regards,
Carsten

1 Like
(Proquibas) #6

Hi @pulsar,
In your case I think that the correct query is:

SHOW TAG VALUES WITH KEY = “hostname” WHERE hostgroup = ‘Linux_Server_Grp’

Regards.

#7

Hello,

the two querys returns nothing:

icinga@icinga2:~> influx -database icinga2influx -execute 'SHOW TAG VALUES WITH KEY = "hostname" WHERE hostgroup = 'Linux_Server_Grp''
icinga@icinga2:~>

Thx @Carsten I will look in your link and hope I find a way to come on the hostnames in the Group

(Proquibas) #8

Hi @pulsar,

Try this:

SHOW TAG VALUES WITH KEY = “hostname” WHERE hostgroup =~ /Linux_Server_Grp/

Regards.

1 Like
#9

Hey that is fantastic :grinning:

Thanks, I would never have gotten that idea.

Now I come to the servers. The problem is solved