Below is an example of a script for simple monitoring, pressing 1 or 2 to send OK or Failure.


The purpose of this example is only to demonstrate how calls should be made to the webhook monitoring created by 1P.


The script collects the data in your application or dependency, interprets the result and delivers it to 1P according to the instructions in the “Hits and Failures” box presented on the page of your registered application in OnePlatform.


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