Uploaded image for project: 'OpenNMS'
  1. OpenNMS
  2. NMS-10552

Slack-compatible notification strategies expect "url" for switch name, should be "-url"

    XMLWordPrintable

    Details

      Description

      Steps to reproduce:

      Configure a notification command in notificationCommands.xml as follows:

          <command binary="false">
              <name>slack_channel_operations</name>
              <execute>org.opennms.netmgt.notifd.SlackNotificationStrategy</execute>
              <comment>Send messages to the #operations channel on Slack</comment>
              <argument streamed="false">
                  <switch>-subject</switch>
              </argument>
              <argument streamed="false">
                  <switch>-tm</switch>
              </argument>
              <argument streamed="false">
                  <substitution>https://hooks.slack.com/services/ASDF/GHJKL/ZXCVBNMQWERTYUIOP</substitution>
                  <switch>-url</switch>
              </argument>
           </command>
       

      Hit it with a notification.

      Expected result: Notification sent to channel associated with the webhook specified with the -url switch substitution

      Actual result: Notification fails to be sent, with the following appearing in notifd.log:

      2019-02-04 22:04:13,846 DEBUG [NotificationTask-0] o.o.n.n.ClassExecutor: Going for the class instance: org.opennms.netmgt.notifd.SlackNotificationStrategy
      2019-02-04 22:04:13,860 DEBUG [NotificationTask-0] o.o.n.n.ClassExecutor: org.opennms.netmgt.notifd.SlackNotificationStrategy class created: class org.opennms.netmgt.notifd.SlackNotificationStrategy
      2019-02-04 22:04:13,861 DEBUG [NotificationTask-0] o.o.n.n.AbstractSlackCompatibleNotificationStrategy: Trying to get Webhook URL from notification switch url
      2019-02-04 22:04:13,861 DEBUG [NotificationTask-0] o.o.n.n.AbstractSlackCompatibleNotificationStrategy: Trying to get Webhook URL from system property org.opennms.netmgt.notifd.slack.webhookURL
      2019-02-04 22:04:13,861 WARN  [NotificationTask-0] o.o.n.n.AbstractSlackCompatibleNotificationStrategy: Could not determine value for Webhook URL from notification command switch url or system property org.opennms.netmgt.notifd.slack.webhookURL
      2019-02-04 22:04:13,861 ERROR [NotificationTask-0] o.o.n.n.AbstractSlackCompatibleNotificationStrategy: No webhook URL specified as a notification command switch or via system property org.opennms.netmgt.notifd.slack.webhookURL. Cannot continue.
      2019-02-04 22:04:13,861 ERROR [NotificationTask-0] o.o.n.n.AbstractSlackCompatibleNotificationStrategy: send: url must not be null
      2019-02-04 22:04:13,861 DEBUG [NotificationTask-0] o.o.n.n.NotificationTask: command slack_channel_operations return code = 1
      

      Workaround: Specify the webhook url using switch url rather than -url (omit the leading dash character)

       

      Update: An equivalent problem exists with the -username, -iconurl, -iconemoji, and -channel switches. These problems can be worked around in the equivalent way as described for -url above.

        Attachments

          Activity

            People

            Assignee:
            ranger Benjamin Reed
            Reporter:
            jeffg Jeff Gehlbach
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration