Application Monitoring documentation

Traditional uptime monitoring means our robots actively test given server or URL address against HTTP response (code and whether given keyword exists in the document body). Application monitoring uses an opposite manner. The application, worker or anything else sends a signal to our API.

You can configure how often this signal has to be sent to recognise the app working correctly. The most usual use case is sending a signal every time a CRON job finishes without an error.

If, for example, your CRON job should execute every day. You can configure the test so if there is no signal every 25 hours our system would consider this test as failing and trigger an alarm.

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:

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();