notificationsmonitoringicinga

Why Icinga2 telegram notification fails in specific services?


I have created custom telegram notification very similar to email notifications. The problem is that it works for hosts and most of the services but not for all of them.

I do not post the *.sh files in scripts folder as it works!

In constants.conf I have added the bot token:

const TelegramBotToken = "MyTelegramToken"

I wanted to manage telegram channels or chat ids in users file, so I have users/user-my-username.conf as below:

object User "my-username" {
    import "generic-user"

    display_name = "My Username"
    groups = ["faxadmins"]

    email = "my-username@domain.com"
    vars.telegram_chat_id = "@my_channel"
}

In templates/templates.conf I have added the below code:

template Host "generic-host-domain" {
    import "generic-host"
    vars.notification.mail.groups = ["domainadmins"]
    vars.notification["telegram"] = {
        users = [ "my-username" ]
    }
}

template Service "generic-service-fax" {
  import "generic-service"
  vars.notification["telegram"] = {
        users = [ "my-username" ]
  }
}

And in notifications I have:

template Notification "telegram-host-notification" {
  command = "telegram-host-notification"
  period = "24x7"
}

template Notification "telegram-service-notification" {
  command = "telegram-service-notification"
  period = "24x7"
}

apply Notification "telegram-notification" to Host {
  import "telegram-host-notification"

  user_groups = host.vars.notification.telegram.groups
  users = host.vars.notification.telegram.users

  assign where host.vars.notification.telegram
}
apply Notification "telegram-notification" to Service {
  import "telegram-service-notification"

  user_groups = host.vars.notification.telegram.groups
  users = host.vars.notification.telegram.users

  assign where host.vars.notification.telegram
}

This is all I have. As I have said before it works for some services and does not work for other services. I do not have any configuration in service or host files for telegram notification.

To test I use Icinga web2. Going to a specific service in a host and send custom notification. When I send a custom notification I check the log file to see if there is any error and it says completed:

[2017-01-01 11:48:38 +0000] information/Notification: Sending reminder 'Problem' notification 'host-***!serviceName!telegram-notification for user 'my-username'
[2017-01-01 11:48:38 +0000] information/Notification: Completed sending 'Problem' notification 'host-***!serviceName!telegram-notification' for checkable 'host-***!serviceName' and user 'my-username'.

I should note that email is sent as expected. There is just a problem in telegram notifications for 2 services out of 12.

Any idea what would be the culprit? What is the problem here? Does return of scripts (commands) affect this behaviour?

There is no Telegram config in any service whatsoever.


Solution

  • Some telegram commands may fail due to markdown parser. I've encountered this problem: If service name has one underscore ('_'), then parser will complain about not closed markdown tag and message will not be sent