Send LibreNMS notifications with Gotify

Hi folks, for those of you that love self-hosting and have a home lab or just use LibreNMS for it’s amazing capabilities and moreover Gotify to have a Central Notification HUB with a nice look that can be organized into applications.

I won’t get in to details of each application and how they work, because of the extent of both of them, that indeed will need a few posts, but here is a little recipe to get the 2 working together.

LibreNMS has a lot of “Transports” or integrations that makes it possible to send notification to a lot of 3rd party services, even e-mail.

But sadly it does not have any integrations with Gotify, but, you can configure an API Request that can definitely kick it into gears, it’s very simple, just get into Alert Transport from the Alerts Menu:

In the Transport page, click on “Create alert transport” and introduce the following:

Note that you have the correct header defined as application/json

Be sure to replace [URL GOTIFY SERVER] with your actual server URL and the [TOKEN FROM YOUR APP FROM GOTIFY] with the token provided by Gotify then creating the app.

If you read the documentation from API Transports on LibreNMS site you can send the entire message from the Alert Code, but, after a lot of testing and fiddling I could not make it work, the problem relies into JSON parsing (or the lack of on the api.php file from LibreNMS) so limiting the Message to name, timestamp, hostname and title worked for me, and the info in the message sent to Gotify is enough for me to realize there is something not working ok.

Here is the code for copypasta joy:

{
"title": "{{ $title }}",
"message": "{{ $name }} - TimeStamp: {{ $timestamp }} - Hostname: {{ $hostname }}",
"priority": 9
}

Hope this makes of use to you as it does to me.

Regards.

Axzel.