Hi,
My workplace are in the process of moving from Slack to g suite, and thus I wanted to move my current webhook notification to google chats. The slack webhook was super easy to setup, and the notifications were very useful and easily customizable, which I'm trying to replicate. (I just want Group, Name, Sensor etc, nothing fancy)
A bit of documentation I've been following: https://developers.google.com/hangouts/chat/how-tos/webhooks https://developers.google.com/hangouts/chat/reference/message-formats/basic
However I could not get webhooks to work with google so I am trying to use Execute HTTP Action instead.
I've entered the required details (URL, No SNI, Method: POST, and a payload of: { "text": "Hello, world" }
I have tested the above to prove my google chat works https://reqbin.com/ and it was successful. But that is JSON which PRTG cant use?
I have tried this and it still didn't work: https://helpdesk.paessler.com/en/support/solutions/articles/69937-how-do-you-send-http-post-data-properly-through-prtg
In the notification logs am getting a HTTP 400 error which I think indicates that the incorrect format was used.
I am not a programmer so this is a bit out of my skill set.
I see I am not allowed to use XML or JSON in the payload So my question is what format does PRTG HTTP Post send ?
To summarize: I want to send notifications to google chats (which I think wants json format, but PRTG cant send) about down devices with name,ip,sensor etc.
Article Comments
Thanks
I've turned on logging but not yet been able to restart the service.
You say that I CAN use JSON in the payload but the tip on PRTG says I cannot. Conflicting information. Can you clarify which is true?
Mar, 2020 - Permalink
Hi there,
Excuse me, you're right here. I was thinking of the HTTP Advanced Sensor here, which supports the JSON format, the notifications indeed don't.
Therefore, the second variant to write a script for the notification to send the JSON via POST would be the way to go.
Kind regards,
Felix Saure, Tech Support Team
Mar, 2020 - Permalink
OK I have found a format that google chat likes using powershell.
$uri = "https://chat.googleapis.com/mywebhookaddress"
$body = ConvertTo-JSON @{ text = 'Hello Channel' }
Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json'
I can run that in powershell directly and it works.
However I cannot get PRTG to execute it via a notification. The log shows the following error:
Error sending "EXE": Error1. MyPRTGServerName : The term 'MyPRTGServerName' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 ch
I've done some googling and searched on here. My PRTG installation is 64bit, I've set the execution policy to remote signed on 32bit powershell but its still not working.
Any suggestions? I'm a newbie to this. Thanks
Mar, 2020 - Permalink
Hi Richard,
I'm afraid that customizing of such scripts is not part of our usual support, maybe the community can help out here. According to the error message, MyPRTGServerName needs to be replaced by the actual server name.
Kind regards,
Felix Saure, Tech Support Team
Mar, 2020 - Permalink
Hello there,
Not at the very moment natively I'm afraid. Using custom notifications is still possible if it's required in your environment. You can then forward parameters to the script to also use the same notification script for different notification templates.
Kind regards,
Felix Saure, Tech Support Team
Oct, 2020 - Permalink
Hi there,
Putting a JSON in the payload of an HTTP Post request should indeed be the way to go. You can open the Notification Delivery Logging to exactly see what's getting send by the notification to see if Google accepts it. Next to this, you always have the possibility to create your very own script to do this and execute the notification via the Execute Exe/Script notification type.
Kind regards,
Felix Saure, Tech Support Team
Mar, 2020 - Permalink