Below is an example of a script for simple monitoring, where you can press 1 or 2 to send "OK" or "Failure" via webhook. The purpose of this example is to demonstrate how the calls should be made for monitoring using the webhook created by the platform.
The script collects data from your application or dependency, interprets the results, and delivers them to the platform according to the instructions of "Hits and Failures" presented in the box on your application's page registered on the platform.
Example:
#!/bin/bash
echo "Failure ou OK?"
echo "1. Failure"
echo "2. OK"
read status
echo "-------------"
token=`curl --request POST \
--url https://apis.elven.works/external/auth/v1/client/<Your Company URL> \
--header 'Content-Type: application/json' \
--data '{
"client_id": "<YOUR INFORMATION HERE>",
"client_secret": "<YOUR INFORMATION HERE>" }' | sed 's/{"access_token":"//g' | sed 's/","expires_in":300,"token_type":"Bearer"}//g'`
if [ $status == 2 ]; then
echo "OK"
curl -X POST -H 'Content-type: application/json' -H "Authorization: Bearer $token " https://apis.elven.works/external/monitoring/v1/hits --data '{"latency": 100000, "service": <YOUR SERVICE ID HERE>, "organization": "<YOUR ORGANIZATION ID HERE>"}'
fi
if [ $status == 1 ]; then
echo "Failure"
curl -X POST -H 'Content-type: application/json' -H "Authorization: Bearer $token " https://apis.elven.works/external/monitoring/v1/failures --data '{"issue": "<Your message>", "service": <YOUR SERVICE ID HERE>,"organization": "<YOUR ORGANIZATION ID HERE>"}'
fi
For questions, inquiries, or technical support, please contact us through the chat on the ElvenWorks platform or on our website.
Comments
0 comments
Please sign in to leave a comment.