I’m trying to create an alert from a windows script using curl.
I have created an alert with a simple expected payload
{ "Source": "$SOURCE", "Status": "$STATUS" }
What format should I use? I’ve tried different variations on the below, and pretty sure I get a connection, but I’m not passing the data correctly (no Alert is generated).
The existing scripts are not powershell, but future ones may be. Thanks for the suggestion.
@aread007 This is so cool, can you show us the end result? What was the usecase behind this? I wonder if we should let the Freshservice API Product team know so that they can add it to the documentation! Great work!!!
@aread007 This is so cool, can you show us the end result? What was the usecase behind this? I wonder if we should let the Freshservice API Product team know so that they can add it to the documentation! Great work!!!
Thanks Zach,
First, this was mainly trial and error. This was a proof of concept. I hope this enough for myself (and others now) to extend on.
My notes below are a little rushed, but hopefully fill in some gaps.
In the Alerts Module, I selected Add monitoring tool.
I selected Webhook (as opposed to one of the preconfigured integrations)
For Configure alert payload I created a very simple structure:
{ "Source": "$SOURCE", "Status": "$STATUS" }
I then mapped the $SOURCE to the Subject and Resource fields in the Alert config (See screenshot at the end of this post)
To raise alert , I just call this command in a script:
So, my use case was a script that looks for a file in a directory, and if it exists, FTP’s the file to another location. The script runs every 10 minutes. The file transfer is not time critical, as long as it happens within 24 hours, it is fine. On error, the script branches to the raise alert. If after a number of retries the transfer is successful, the clear alert curl is run. This sets the Alert to Clear. If an incident had been raised, it will also close the incident related to the Alert (based on the Alert Rules configuration).
The Alert Rules in Freshservice let you decide under what conditions to raise an incident for an alert. I haven't had a good look, but it appears that Workflow Automator does not deal with Alerts, so hopefully the Alert Rules is flexible enough to deal with most situations.
Other Points:
I tried passing the auth key as a header, but couldn’t get this working. I don't think including the auth key in the URL is good practice. I have now seen some examples if the general API documentation on how to pass this auth key outside of the URL, I just haven’t tested it yet.
My Proof of Concept only passed two items. It would be better to pass more information to an alert, and use variables in the curl command to pass these. e.g. error message, a user friendly description….
IMAGE 3: Webhook Config
Regards,
Andrew
Maybe my last post.
Here is how to move the apikey out of the URL and into a header: