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/ \
--header 'Content-Type: application/json' \
--data '{
"client_id": "",
"client_secret": "" }' | 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": , "organization": ""}'
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": "", "service": ,"organization": ""}'
fi