I have the same exact situation. I "fixed" the 3 alert-messages problems by changing "Attempts" from 3 to 1 in the Slack media type Options. But I still get every now and then "invalid_auth" for some alerts even though they do come through into Slack. Every single Resolved-message fails in "channel_not_found".
Ad Widget
Collapse
Getting working the Slack Bot
Collapse
X
-
Comment
-
Thanks to the advice in this thread and the linked Jira issue I've found a fix for slack notifications on Zabbix 5.2.6.
The issue was in the `getPermalink` method - the script was posting to slack correctly, but failing to get a link to the posted message. It was then trying to tag the problem with the message link so it could be updated automatically when the problem was resolved.
This caused the problems with the resolved messages as well - they couldn't find the original message to update.
Slack's documentation says that `getPermalink` is a `GET` method, but it appears to only accept `POST`.
Here's a fixed `getPermalink` method - replace the one in your script and hopefully it should work:
You don't need to make the change to `{EVENT.UPDATE.STATUS}` as posted earlier - that sidestepped the problem by not trying to update messages at all.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.Post(Slack.getPermalink + '?channel={0}&message_ts={1}'.format( channelId, messageTimestamp ), 'token='+params.bot_token) ); if (req.Status != 200 && !resp.ok) { throw resp.error; } return resp.permalink; }Comment
-
-
Thanks a very lot to digi412! - I did now use the original webhook template without any other modification than replacing the getPermalink, as you mentioned, and now it seems to work (although I did believe that already a few times were it worked one or two times and then failed again...). However, I tried several times with success. A last doubt I have: Maybe if too many notifications in a too short period, Slack limits messages per second or minute and then makes them fail again. Maybe - I will keep an eye on that.Comment
-
Worked for me too! Well mostly. Some messages still don't come through and then at some point I started to witness a weird phenomenon: A Problem would come through to Slack only to be _replaced_ by a Resolved-message when one came through. Then it started spamming a ton of resolved messages and I had no problems on the Slack channel to connect them to.Comment
-
I can post to the channel. Zabbix can send the problem to the channel ok. It's just the resolved part that seems to go wrong.
That is the weird part. It's already posted to the channel so it knows the channel is there. I have the permalink fix above (without that the problem message fails even though it appears in slack 3 times)
It worked once for me ok. The only thing I can see there is on that message in slack it has event tags as none and now it has [] there on the later messages
I feel the problem is in the getPermalink function somehowComment
-
Here is my current script, which is working.Attached FilesComment
Comment