If I were building a Grafana table similar to LibreNMS’s Alerts > Alert History using the Grafana time selector I would try…
SELECT `alert_log`.`time_logged`,`devices`.`hostname`,`alert_rules`.`name`
FROM `alert_log`,`alert_rules`,`devices`
WHERE `alert_log`.`device_id` = `devices`.`device_id`
AND `alert_log`.`rule_id` = `alert_rules`.`id`
AND `alert_log`.`state` != 0
AND `alert_rules`.`disabled` != 1
AND `devices`.`disabled` = 0
AND $__timeFilter(`alert_log`.`time_logged`)
If I just wanted a table with current alerts, similar to the LibreNMS Alerts > Notitications I would try…
SELECT `alerts`.`timestamp`,`devices`.`hostname`,`alert_rules`.`name`
FROM `alerts`,`alert_rules`,`devices`
WHERE `alerts`.`device_id` = `devices`.`device_id`
AND `alerts`.`rule_id` = `alert_rules`.`id`
AND `alerts`.`state` != 0
AND `devices`.`disabled` = 0
And event log table with Grafana time selector should be similar…
SELECT `eventlog`.`datetime`,`devices`.`hostname`,`eventlog`.`message`,`eventlog`.`type`,`eventlog`.`severity`
FROM `devices`,`eventlog`
WHERE `eventlog`.`device_id` = `devices`.`device_id`
AND `devices`.`disabled` = 0
AND $__timeFilter(`eventlog`.`datetime`)