Application Monitoring documentation
With Application Monitoring AgentSlug waits for your application to tell whether it's healthy or not.
For example, if you worker executes something every hour, it would send a signal to our API. When there is no signal for a given time, you get a notification.
You can configure how often this signal has to be sent to recognise the app working correctly.
Application Monitoring documentation
Configuration
In order to send first ping singal you need to get two things: API token and Application Monitoring test ID.
API token
Once you're logged in to the app, simply head on to API tokens section under "your account".
There you can simply just click the "create new token button". This will create a token which then can be use for ping test authentication. Copy and paste it somewhere save.
Please note, this token gives credentials to anyone using it to do changes on your account. Keep it safe and DO NOT publish it anywhere public.
Application Monitoring test ID
This is just an ID of the test. You need to create one so our system knows what to test.
To do that, go to your ping tests page and create new test.
While creating the test, choose and alarm timeout wisely.
If your worker, or cron job is triggered every minute, it's common to set it up little higher. Like 3 minutes.
In short words: this is the time after our service considers the job to be failing. If we don't get any signal for 3 minutes. Alarm is triggered.
Once the test is created, simply copy the test ID visible in the test card.
Almost ready!
Once you get two things which are required: API token and test ID, now it's time to implement it in your code.
Don't worry, the test won't trigger any alarms before first signal from your application reaches AgentSlug.com API.
How to implement it exactly:
Sending the signal is technology agnostic. There is only one requirement: be able to send HTTP POST request to api.agentslug.com.
CURL example
This is the easiest example, that you can simply run in your terminal. It should work since CURL is installed nearly everywhere.
curl --request POST \
--url https://api.agentslug.com/ping/[TEST_ID}/heartbeat \
--header 'authorization: Bearer [YOUR_API_TOKEN]'
Node.js
For node.js application we have prepared an npm package / SDK.
You can simply add it to your dependencies and use it as described in the readme
PHP example
Since PHP SDK is still in plans, here's a quick code snippet you can just copy and paste into your app:
$request = new HttpRequest();
$request->setUrl('https://api.agentslug.com/ping/[TEST_ID]/heartbeat');
$request->setMethod(HTTP_METH_POST);
$request->setHeaders(array(
'authorization' => 'Bearer [YOUR_API_TOKEN]'
));
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Java
Same as PHP. No Gradle package yet, but here's a snippet:
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder()
.url("https://api.agentslug.com/ping/[TEST_ID]/heartbeat")
.post(null)
.addHeader("authorization", "Bearer [YOUR_API_TOKEN]")
.build();
Response response = client.newCall(request).execute();