Hi, I would like to know if there is any practical way to be able to display information about Zabbix - Host availability on Grafana panels:
Total value I’m getting via the
Not available and
Unknown can be obtained via the
According to the documentation the possible values of the key
- 0 - not available
- 1 - available
- 2 - unknown
The type of view I want to use to view the host values is Stat:
To run some tests, I’m currently using the table view.
I’m using the following transforms, this way I can filter only the values corresponding to the status
1 - available
The problem: I’m not able to add the number of items to get a total value of hosts available.
In this example, I have hosts
0 - not available:
I have the same exact issue. I want to create a simple dashboard that shows in easy to read stats the availability of hosts and/or services running on the hosts.
So let’s say we have 300 servers of which at any given time most are up’n running, but some may be unavailable. I’d like to be able to visualise a single or two separate panels showing a how many hosts are available and how many are not.
I’ve been going through transformations, but I can’t seem to be able to make it happen. Instead of a single panel with a single number of hosts, I get a panel with a gazillion hosts all showing either a 1 or a 0 for availability.
I’m also using Zabbix as a source for Grafana.
If anyone has any ideas on how to accomplish this, please let me know.
Still looking for a solution. Can anyone elaborate to solve this?
Hi, good morning
I performed the visualization of the triggers by group, however, for this it was necessary to use database queries, it is possible to do what you are requesting, however, it will have to be through queries in the database. Hope I helped!
I’ll see if I can get the code to pull this data, but I don’t promise, I came here just to shed some light…
below I will leave an image that deals with the triggers I pulled through the database
This is exactly the type of data we too would need to get into Grafana from Zabbix. If you could find some code to share, that would be awesome!
I will send it here, pay attention to what I write and let me know if you have any questions.
1° The Datasource needs to be your Database
2° There must be a variable with the name “group” that takes all the zabbix groups or the groups you want
3° The priorities in the SQL code will be defined as:
0 - No
1 - Information
2 - Warning
3 - Average
4 - High
5 - Disaster
4° It is also necessary to use the “Stats” dashboard
Below I will send the SQL code and the place where there will be a replacement
COUNT(DISTINCT triggers.triggerid) AS metric
LEFT JOIN hosts_groups
ON hstgrp.groupid = hosts_groups.groupid
LEFT JOIN hosts
ON hosts_groups.hostid = hosts.hostid
LEFT JOIN items
ON hosts.hostid = items.hostid
LEFT JOIN functions
ON items.itemid = functions.itemid
LEFT JOIN triggers
ON functions.triggerid = triggers.triggerid
hstgrp.name = ‘$group’ AND
hosts.status = 0 AND
hosts.maintenance_status = 0 AND
items.status = 0 AND
triggers.status = 0 AND
triggers.value = 1 AND
triggers.priority = 1; // Change the trigger priority as desired, from 0 to 5 as explained above.
Thanks for the SQL-code! That helped me move on quite a bit.
Just a quick question:
The panel “Hosts Window Servers” with the pie chart… How did you pull those numbers from the database? I’ve used the code you posted here and tweaked it a bit to get host count instead of trigger count, but I cannot seem to be able to figure out how to get the number of OK-hosts.
So I get the number of the 20 hosts in a group correctly. There are 4 averages and 2 warnings which are correct. But my OK comes out as 19 out of 20 instead of 16. So that’s obviously wrong.
Hey, how’s it going?
Your observation is interesting, however, there is a difference in this dashboard.
This Donut dashboard doesn’t show the alerts but the hosts that are alerting, so it contains “Ok” first, for example.
In this dashboard I made, I made a point of showing the alarms and number of hosts that are alarming with the severities.
Just below I made a dashboard that shows the name of the servers and what alarms they have, and clicking on any one is redirected to a dashboard for that specific host.
Referring to the code of this pizza (or donut) dashboard, I will send you here.
UNIX_TIMESTAMP(NOW()) as time_sec,
name as metric,
IFNULL(count,0) as value
(SELECT 0 as priority, ‘1 - Not classified’ as name
UNION SELECT 1, ‘2 - Information’
UNION SELECT 2, ‘3 - Warning’
UNION SELECT 3, ‘4 - Average’
UNION SELECT 4, ‘5 - High’
UNION SELECT 5, ‘6 - Disaster’
UNION SELECT 6, ‘0 - OK’) as tmp1
LEFT JOIN (SELECT IFNULL(tmp.priority,6) as priority, count(h.hostid) as count
FROM hstgrp g, hosts_groups hg, hosts h
LEFT JOIN (SELECT h.hostid, max(priority) as priority FROM hstgrp g, hosts_groups hg, hosts h, items i, functions f, triggers t
LEFT JOIN trigger_depends td ON t.triggerid=td.triggerid_down
LEFT JOIN (SELECT triggerid, value FROM triggers WHERE status=0) as t2 ON td.triggerid_up=t2.triggerid
WHERE g.groupid=hg.groupid and
(t2.value=0 or t2.value is null)
GROUP BY h.hostid) as tmp ON h.hostid=tmp.hostid
g.name = ‘$grupo’ and
tmp.priority) as tmp2 ON tmp1.priority=tmp2.priority