Alert Transport not working

[root@librenms librenms]# ./validate.php

Component Version
LibreNMS 1.40-29-g5af520a
DB Schema 252
PHP 7.1.16
MySQL 5.7.18
RRDTool 1.4.8
SNMP NET-SNMP 5.7.2

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

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

I just setup the Rocket.Chat transport. If I use the “Test Transport” button in LibreNMS, I get the alert. However, I caused a device in LibreNMS to issue the default up/down alarm and I did not get the alert. I did get an e-mail as I expect, but in the “Recent Events” of the device in question it only says:

Issued recovery for rule ‘Devices up/down’ to transport ‘mail’

I’ve looked through the documentation and on here, but I can’t figure out what’s wrong. Am I missing something stupid simple? How can I get the default templates to issues alerts to transports other than mail?

I have the rocket.chat transport setup as well and it is working for me but our alert settings may be different. Also, I recall when I was setting up the transport my webhook code was causing some issue but that may or may not be the case for you. Are you seeing anything in the rocket.chat logs that would point out an issue?

In any event this is how my setup is, hopefully this helps.

Under global settings → alert settings → General options:

This is a generic alert template that I know works for device down:

%title
Severity: %severity
{if %state == 0}Time elapsed: %elapsed
{/if}Timestamp: %timestamp
Description: %description
%sysName 
Rule: {if %name}%name{else}%rule{/if}
{if %faults}Faults:
{foreach %faults}  #%key: %value.string
{/foreach}{/if}Alert sent to: {foreach %contacts}%value <%key> {/foreach}
View: http://myawesomenmsurl.com/device/device=%device_id/tab=alerts/

On the rocket.chat side I am using this for the webhook script section:

process_incoming_request({ request }) {
    // request.url.hash
    // request.url.search
    // request.url.query
    // request.url.pathname
    // request.url.path
    // request.url_raw
    // request.url_params
    // request.headers
    // request.user._id
    // request.user.name
    // request.user.username
    // request.content_raw
    // request.content

    // console is a global helper to improve debug
    console.log(request.content);

    return {
      content:{
        text: request.content.text
       }
    };

    return {
       error: {
         success: false,
         message: 'Error example'
       }
     };
  }
}

Thanks for the suggestion! I was using a Webhook that is already utilized by my vCenter servers and I was setting the options in LibreNMS for the icon_url and channel. However, I created a new incoming Webhook specifically for LibreNMS with no custom options in LibreNMS and it finally worked.

2018-06-22 17:21:08||Issued critical alert for rule 'Devices up/down' to transport 'rocket'

2018-06-22 17:21:07||Issued critical alert for rule 'Devices up/down' to transport 'mail'

So I guess LibreNMS didn’t like the custom options for some reason.

Also, I’m not using any custom script(s) on the Incoming Webhook or any custom Alert template in LibreNMS, all defaults there.

Good to hear its working for you! My issue was similar as well, I was using zenoss with a webhook and the script was messing it up. Once I created a different webwook I used the script I pasted in my earlier reply and it worked just fine, even formatted way better then the old zenoss alerts, actually much happier with librenms after the change.

I’ll try out the webhook script to see what it looks like compared to default formatting. TBH I haven’t messed with the Rocket.Chat incoming webhook script for LibreNMS, PRTG, or vCenter alerts I setup.

Oh the script is just for debugging if needed, afaik all the formatting comes from the way librenms sends the alert, and it does a damn good job of doing it imo. I’m still kinda new to librenms so I get super excited when anything works better than zenoss lol

Oh okay derp lol

I’m newer to Rocket.Chat than I am LibreNMS. I actually moved all of my works routers/switches/servers to LibreNMS from Observium last year just for alerting.