I have created a warning alert for possible layer 2 loops.
I have a working query and when I run a capture for alerts it also shows as “matches” but doesn’t show up anywhere. I was wondering if there are required fields I need to include in custom SQL alerts?
Here is my SQL:
SELECT
devices.device_id,
ports_fdb.mac_address,
vlans.vlan_vlan AS vlan,
GROUP_CONCAT(DISTINCT ports.ifDescr SEPARATOR ', ') AS ports
FROM ports_fdb
JOIN vlans ON ports_fdb.vlan_id = vlans.vlan_id
JOIN ports ON ports_fdb.port_id = ports.port_id
JOIN devices ON ports_fdb.device_id = devices.device_id
WHERE ports_fdb.device_id = ?
GROUP BY ports_fdb.mac_address, ports_fdb.vlan_id
HAVING COUNT(DISTINCT ports_fdb.port_id) > 1
And here is my capture when I run the alert on a device that should alert:
Rule name: Possible Layer 2 Loop
Alert rule: Custom SQL Query
Alert query: SELECT
devices.device_id,
ports_fdb.mac_address,
vlans.vlan_vlan AS vlan,
GROUP_CONCAT(DISTINCT ports.ifDescr SEPARATOR ', ') AS ports
FROM ports_fdb
JOIN vlans ON ports_fdb.vlan_id = vlans.vlan_id
JOIN ports ON ports_fdb.port_id = ports.port_id
JOIN devices ON ports_fdb.device_id = devices.device_id
WHERE ports_fdb.device_id = ?
GROUP BY ports_fdb.mac_address, ports_fdb.vlan_id
HAVING COUNT(DISTINCT ports_fdb.port_id) > 1
Rule match: matches
It never shows in alert logs or dashboard for this device even though it confirms a match.
Edit: Also tried adding *, to the select query but it still isn’t showing.
@laf your help is appreciated but I can’t find any documentation on what fields are required. As I mentioned earlier I had tried a wildcard in the SELECT statement but librenms gets upset when you don’t include a column in the GROUP BY.
As asked in the title of the thread, what fields are required to show up on the alerts?
There is no documentation about this in docs.librenms.org