API Alert Transport

====================================

Component Version
LibreNMS 1.58.1-66-ga0e9716
DB Schema 2019_12_16_140000_create_customoids_table (149)
PHP 7.2.7
MySQL 5.5.56-MariaDB
RRDTool 1.4.8
SNMP NET-SNMP 5.7.2

====================================

[OK] Composer Version: 1.9.1
[OK] Dependencies up-to-date.
[OK] Database connection successful
[OK] Database schema correct

I’m having to move away from Rocket.Chat to a new messaging service called Flock. They handle incoming web hooks differently, so I’m trying to figure out how to get alerts sent to a Flock channel. Looking through the list of LibreNMS alert transports, I think the API option is my best bet. I’ve read through the API transport documentation but I’m not entirely clear on how to approach this. Does LibreNMS send the alert in JSON format?

From the LibreNMS documentation:

The API-Option fields can be directly built from the variables defined in Template-Syntax but without the 'alert->' prefix. For instance, $alert->uptime is available as $uptime in the API transport

If I’m understanding this correctly, I can specify API options in a transport template? Can I specify JSON in the alert templates?

I’ve refactored my vSphere alerts to comply with Flock’s formatting, so I’m just trying to figure out how exactly LibreNMS is sending data and how I can manipulate it.

Any help, guidance, or examples on how to format this in the alert transport template would be helpful.

Thanks

Hi
The API code does not currently send anything as JSON. You can generate GET or POST or PUT calls, with options. PUT also accepts a body (never used that one).

If you need JSON, then you probably should use the Api Transport Code as a base, and create your own transport.

Code: https://github.com/librenms/librenms/blob/master/LibreNMS/Alert/Transport/Api.php