Ad Widget

Collapse

Querying for latest item's values from the zabbix database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aleksander237
    Junior Member
    • Apr 2022
    • 13

    #1

    Querying for latest item's values from the zabbix database

    Hello,

    I'm using grafana along with grafan zabbix datasource. I'm struggling in the situations where I want to present some data in the form of table. For example, I'm monitoring switches and I want to present network interfaces in the form of table. My current approach is to walk interfaces, create the dependent item which preprocesing data to JSON. Then I query for the data in grafana:

    Code:
    select * from json_table(
    (SELECT ht.value FROM hosts h
    INNER JOIN items i ON h.hostid = i.hostid
    INNER JOIN history_text ht ON i.itemid = ht.itemid
    WHERE h.name = '$host' AND i.key_ = 'procurve.interfaces.json'
    ORDER BY ht.clock DESC LIMIT 1)
    , '$[*]'
    columns(
    `Index` INTEGER path '$.ifIndex',
    `Description` VARCHAR(255) path '$.ifDescr',
    `Type` INTEGER path '$.ifType',
    `Speed` INTEGER path '$.ifSpeed',
    `MAC` VARCHAR(255) path '$.ifPhysAddress',
    `Admin Status` INTEGER path '$.ifAdminStatus',
    `Oper. Status` INTEGER path '$.ifOperStatus',
    `Last Change` INTEGER path '$.ifLastChange',
    `In Octets` INTEGER path '$.ifInOctets',
    `In Discards` INTEGER path '$.ifInDiscards',
    `In Errors` INTEGER path '$.ifInErrors',
    `Out Octets` INTEGER path '$.ifOutOctets',
    `Out Discards` INTEGER path '$.ifOutDiscards',
    `Out Errors` INTEGER path '$.ifOutErrors'
    )
    ) AS `table` ORDER BY `index`;
    I'm wondering if there is a better way to do it. Is the latest value of item easily (without too many joins) accessible from the database
Working...