Ad Widget

Collapse

Getting working the Slack Bot

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gadg3ts
    Junior Member
    • Jan 2020
    • 11

    #1

    Getting working the Slack Bot

    Hi,
    I've been trying to get Slack notifications from Zabbix working by a couple of methods, with varying success.
    1) Zabbix Notify - https://github.com/v-zhuravlev/zabbix-notify
    This I had all set up as per the instructions, and I can get it to send a test notification into the alerts channel. However, it wouldn't send anything automatically.

    2) The official "Slack Webhook" - https://www.zabbix.com/integrations/slack
    (after renaming the previous 'Slack' media type from option #1) I managed to get this set up as far as possible according to the instructions.
    However, they're a bit out of date - adding a 'bot user' doesn't exist any longer as described, instead, that stage in the process asks you what API scopes you want to give your bot, which if you've not tried to do this with Slack before, is going to be a bit of a lucky dip.
    Having previously spent some time shouting at Slack when writing a script to automate the inviting of users, I'ver added "chat:write" to both the bot and user scopes as it seemed like the most relevant, but I'm not 100% sure if that's what is required in this case...

    Does anyone know / can point me to what I need to get this working as it should be? or where in Zabbix to find what it's actually sending as the webhook content?..

    Thanks,
    Sean
  • jochristian
    Junior Member
    • Jan 2020
    • 5

    #2
    Hi Gadg3ts,

    Did you find an solution to the official slack webhook solution.
    So far now luck in my installation. When doing an test I only get this response back.

    Code:
    {
        "tags": {}
    }
    /Jo Christian

    Comment

    • CPerson
      Junior Member
      • Mar 2020
      • 1

      #3
      I went through the same issue yesterday as I migrated from the zbx-notify script I had been using for several years. After some testing I found these OAuth scopes to work for me.
      • chat:write
      • chat:write.customize
      • chat:write.public
      Click image for larger version

Name:	Screenshot from 2020-03-13 07-14-40.png
Views:	6746
Size:	40.8 KB
ID:	397558

      Comment

      • andre_tux
        Junior Member
        • Mar 2021
        • 1

        #4
        I am also struggeling to get the Clag notification working. When I test, I also just get the empty tag back, like jochristian.
        I tried the scopes settings that CPerson suggested, but nothing.
        I am using Zabbix 4.4
        Any other ideas to try?

        Thanks
        Andre

        Comment

        • krenaud
          Junior Member
          • Feb 2019
          • 2

          #5
          I am using Zabbix 5.2 and the built in webhook integration. Problems appear in Slack (sent three times), but not resolved items.

          If I look at details for the Event the Problem that has been sent to Slack I get "Slack notification failed : invalid_auth" for the problem (even though it obviously did reach slack all three attempts).

          For the resolved event that does not reach Slack I get "Slack notification failed: channel_not_found".

          Are there any logs or something that can be used for troubleshooting?

          Comment

          • mwildam
            Member
            • Feb 2021
            • 72

            #6
            I have the same problem, but anyway, in my case the messages arrive in slack. Did you invite the bot to the channel? BTW: In my case it does not make any difference, if I write the # in front of the channel name or not.

            Comment

            • mwildam
              Member
              • Feb 2021
              • 72

              #7
              You could try it "by hand" - as Sean does it in this video: https://youtu.be/zZSXEvjpfbY

              Comment

              • mwildam
                Member
                • Feb 2021
                • 72

                #8
                I found a newer, more recent video of Sean again showing the newer Slack integration: https://youtu.be/3-ONmc43vMw - I will watch this, if it shows anything new.

                Comment

                • Zwirni
                  Junior Member
                  • Sep 2019
                  • 5

                  #9
                  Got the same error in a Zabbix 5.2. I think there might be a bug in the script here:


                  In the script for 5.4 there are some fixes that might be solve it. But I could not figure it out until now.

                  Comment

                  • pc99096
                    Senior Member
                    • Oct 2011
                    • 193

                    #10
                    it seems that if you replace the "event_update_status" variable with "1" (instead of {EVENT.UPDATE.STATUS}), it does not fail

                    Comment

                    • Zwirni
                      Junior Member
                      • Sep 2019
                      • 5

                      #11
                      This fixed the three-time problem-message in Slack - but I never get an OK-message. There is the error "channel_not_found" visible.

                      Comment

                      • mwildam
                        Member
                        • Feb 2021
                        • 72

                        #12
                        Originally posted by pc99096
                        it seems that if you replace the "event_update_status" variable with "1" (instead of {EVENT.UPDATE.STATUS}), it does not fail
                        You are my hero - that did the trick! Thanks a lot!

                        Comment

                        • kisarakana
                          Junior Member
                          • Mar 2021
                          • 1

                          #13
                          Hello.
                          I'm also using slack notifications in Zabbix 5.0 and I was able to post to slack but was getting an invalid_auth error.
                          The token is embedded by Get processing with the function getPermalink in the script, but the invalid_auth error disappeared when I modified it as follows.

                          Code:
                          function getPermalink(channelId, messageTimestamp) {
                             var req = new CurlHttpRequest();
                          
                             req.AddHeader('Content-Type: application/x-www-form-urlencoded; charset=utf-8');
                             req.AddHeader('Authorization: Bearer ' + params.bot_token);
                             var resp = JSON.parse(req.Get(
                                '{0}?channel={1}&message_ts={2}'.format(
                                   Slack.getPermalink,
                                   channelId,
                                   messageTimestamp
                                )
                             ));
                          
                             if (req.Status != 200 && !resp.ok) {
                                throw resp.error;
                             }
                          
                             return resp.permalink;
                          }

                          Comment

                          • mwildam
                            Member
                            • Feb 2021
                            • 72

                            #14
                            What the hack... - It worked for a few messages and then refused again. - Channel not found it says.

                            Comment

                            • mwildam
                              Member
                              • Feb 2021
                              • 72

                              #15
                              I tried to apply the changes mentioned here:


                              It looks like it's only working for problem messages and not for recovery messages.

                              Comment

                              Working...