Alert ID Oddity/Issue

I built up an alert template that feeds into a webook with some json and have added the $alert->id into it but it appears that this is not the same alert ID that is listed in the API. I’ve looked around the documentation and don’t see any other id that I can call.

The alert ID I get from the template I set up is ‘alert_id’: ‘1262448’. This is the alert ID I get from the api “id”: 156682 when I use the list alert list API. Is there something else I can call in the template? Is there a reason why these ID’s are different? Is it possibly an issue with my installation of librenms?

===========================================
Component | Version
--------- | -------
LibreNMS | 23.8.2 (2023-08-21T09:48:13-06:00)
DB Schema | 2023_08_02_120455_vendor_ouis_unique_index (257)
PHP | 8.1.11
Python | 3.7.3
Database | MariaDB 10.5.13-MariaDB-1:10.5.13+maria~stretch
RRDTool | 1.7.1
SNMP | 5.7.3
===========================================
[OK] Composer Version: 2.5.8
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database Schema is current
[OK] SQL Server meets minimum requirements
[OK] lower_case_table_names is enabled
[OK] MySQL engine is optimal
[OK] Database and column collations are correct
[OK] Database schema correct
[OK] MySQl and PHP time match
[OK] Distributed Polling setting is enabled globally
[OK] Connection to memcached is ok
[OK] Connected to rrdcached
[OK] Active pollers found
[OK] Dispatcher Service not detected
[OK] Locks are functional
[OK] Redis is unavailable
[OK] rrdtool version ok
[OK] Connected to rrdcached

I’ve not done any templates for a long time, but does $alert->uid match the API?

They are the same, at least from what I’m getting. This is what I get and how I’ve got my template set up.

{‘severity’: ‘critical’, ‘unique-id’: ‘1262448’, ‘alert_id’: ‘1262448’, ‘timestamp’: ‘2023-08-22 16:21:42’}

{“severity”: “{{ $alert->severity }}”,“unique-id”: “{{ $alert->uid }}”,“alert_id”: “{{ $alert->id }}”,“timestamp”: “{{ $alert->timestamp }}”}

The intent is to be able to use the id to feed to the librenms API to acknowledge this alert as it’s going to be used for some automation.

Edit: I just realized that I can accomplish essentially the same thing from the alert rules by limiting to a single alert but would still like to know the answer to the above question.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.