wiki:NSM2021/Agenda/AlertsLibrenms

Version 13 (modified by admin, 3 years ago) ( diff )

--

Sending Notifications and Alerts using LibreNMS.

When a specific event occurs (eg: Link Down) NMS should be able to send administrators some notifications. On LibreNMS this is done by creating different Transports and Alerting Rules. Transports are the mechanism on how LibreNMS should send the alerts (may be by Email, by some API etc.), where Alerting Rules specify when and to whom to send those alerts.

Alert Transports

We need to specify which transport we are going to use.

On your UI, Go to Alerts --> Alert Transports

Email Transport

Email transports needs to be created per email basis. If you need two emails to be notified, You have to create two transports.

Go to Create Alert Transport

  • Transport Name: Email to <Name of Admin1>
  • Transport type: Mail
  • Default Alert: Off
  • Email: <Email Address of Admin1>

Once you save the transport it should see like the following.

Repeat the same for the second Email Address if you have any.


For Email Transports to Work, you need to setup email server details for LibreNMS. Since we haven't installed a public email server, lets use GMAIL as the smtp server.

Log in to https://myaccount.google.com with any of your personal gmail accounts.

Goto Security --> Less secure app access

Enable Allow less secure apps

Next, on your LibreNMS installation,

Goto Settings Wheel --> Global Settings --> Alerting --> Email Options and include gmail settings as per following.

Now go back to the Alert Transport page and click in front of your transports and check whether you received a test mail to your email account/s.

Slack Tranport

Slack ( https://slack.com )is an enterprise messaging platform used worldwide for professional use. Slack supports Web and Mobile versions so that we can use slack to generate alerts on mobile devices. This is done by using its SLACK API and by creating a BOT to message you with the alerts.

If you don't have a slack account for your institute, create one with free plan. (If there are multiple attendees from the same institute, Please create test accounts as it may become an issue later someday. (eg: PDN-test-Lorence) Or else one may create a single account and add/invite others and make them Administrators.

Do first three steps under Getting started with Incoming Webhooks on https://api.slack.com/messaging/webhooks ( Example steps here )

  • Next, Goto your LibreNMS Transport page and create a new transport and test. Use the webhook URL from your SLACK APP

  • If your transport worked, you should see something similar to this on your monitoring channel,

Telegram Transport

Telegram is a well-known messaging platform with many users on Mobile devices. We can create another BOT to send Alerts from LibreNMS to a Telegram Group.

Here we will add the BOT to a Telegram Group so that many users can be included into this group.

Create Telegram BOT

Install Telegram app in to your PC. ( If you are not a Telegram user, download Telegram app to your mobile phone and create an account). Log in using your account.

  • Add BOT Father to your account. https://t.me/botfather
  • Generate a new bot with the command "/newbot" BotFather is then asking for a username and a normal name. After that your bot is created and you get a HTTP token. (for more options for your bot type "/help")
  • Add your bot to telegram with the following url: http://telegram.me/<botname> to use app or https://web.telegram.org/<botname> to use in web, and send some text to the bot.
  • The BotFather should have responded with a token, copy your token code and go to the following page in chrome: https://api.telegram.org/bot<tokencode>/getUpdates (this could take a while so continue to refresh until you see something similar to below)
  • You see a json code with the message you sent to the bot. Note the Chat id. In this example that is “-9787468” within this example: "message":{"message_id":7,"from":"id":656556,"first_name":"Joo","last_name":"Doo","username":"!JohnDoo"},"chat":{"id":-9787468,"title":"Telegram Group"},"date":1435216924,"text":"Hi"}}]}.
  • Create a group with your BOT and add you and few of your colleagues who you needs to be notified. Add some sample messages to the group. Refresh https://api.telegram.org/bot<tokencode>/getUpdates pick the Chat ID of the group chat (which is not of the Bot itself we received earlier).

Next, Setup the Telegram Transport on LibreNMS.

Once you test the transport, you should see similar message on your Telegram Group.

Transport Groups

On the Same Alert Transport page, Create a transport Group. Transport group allows us to set a rule to do alerting on a group of transports. Since we have multiple email address transports, Slack, Telegram, we need you group them before applying them to actual rules.

eg:

Alert Rules

Custom Alert Rules Guide

Attachments (17)

Note: See TracWiki for help on using the wiki.