Inside config/
folder there is a file called monitors.yaml
. We will be adding our monitors here. Please note that your yaml must be valid. It is an array.
Each monitor runs at 1 minute interval by default. Monitor runs in below priorty order.
Sample
1link- name: Google Search
2link description: Search the world's information, including webpages, images, videos and more.
3link tag: "google-search"
4link image: "/google.png"
5link cron: "* * * * *"
6link defaultStatus: "UP"
7link api:
8link timeout: 4000
9link method: POST
10link url: https://www.google.com/webhp
11link headers:
12link Content-Type: application/json
13link body: '{"order_amount":1,"order_currency":"INR"}'
14link eval: |
15link (function(statusCode, responseTime, responseDataBase64){
16link const resp = JSON.parse(atob(responseDataBase64));
17link return {
18link status: statusCode == 200 ? 'UP':'DOWN',
19link latency: responseTime,
20link }
21link })
name | Required | This will be shown in the UI to your users. Keep it short and unique |
---|---|---|
name | Required + Unique | This will be shown in the UI to your users. Keep it short and unique |
description | Optional | This will be show below your name |
tag | Required + Unique | This is used to tag incidents created in Github using comments |
image | Optional | To show a logo before the name |
cron | Optional | Use cron expression to specify the interval to run the monitors. Defaults to * * * * * i.e every minute |
api.timeout | Optional | timeout for the api in milliseconds. Default is 10000(10 secs) |
api.method | Optional | HTTP Method |
api.url | Optional | HTTP URL |
api.headers | Optional | HTTP headers |
api.body | Optional | HTTP Body as string |
api.eval | Optional | Evaluator written in JS, to parse HTTP response and calculate uptime and latency |
defaultStatus | Optional | If no API is given this will be the default status. can be UP/DOWN/DEGRADED |
hidden | Optional | If set to true will not show the monitor in the UI |
category | Optional | Use this to group your monitors. Make sure you have defined category in site.yaml and use the name attribute here |
dayDegradedMinimumCount | Optional | Default is 1. It means minimum this number of count for the day to be classified as DEGRADED(Yellow Bar) in 90 day view. Has to be number greater than 0 |
dayDownMinimumCount | Optional | Default is 1. It means minimum this number of count for the day to be classified as DOWN(Red Bar) in 90 day view. Has to be number greater than 0 |
includeDegradedInDowntime | Optional | By deafault uptime percentage is calculated as (UP+DEGRADED/UP+DEGRADED+DOWN). Setting it as true will change the calculation to (UP/UP+DEGRADED+DOWN) |
ping.hostsV4 | Optional | Array of hosts / IP to monitor ping response. Either domain name or IP4 |
ping.hostsV6 | Optional | Array of hosts / IP to monitor ping response. Either domain name or IP6 |
Kener fills data every minute in UTC so if you give an expression that is not per minute, kener will backfill data using the latest status.
Example for cron: "*/15 * * * *"
Kener will fill data from 18:01:00 to 18:14:00 as UP
This is a anonymous JS function, by default it looks like this.
NOTE: The eval function should always return a json object. The json object can have only status(UP/DOWN/DEGRADED) and lantecy(number)
{status:"DEGRADED", latency: 200}
.
1link(function (statusCode, responseTime, responseDataBase64) {
2link let statusCodeShort = Math.floor(statusCode/100);
3link let status = 'DOWN'
4link if(statusCodeShort >=2 && statusCodeShort <= 3) {
5link status = 'UP',
6link }
7link return {
8link status: 'DOWN',
9link latency: responseTime,
10link }
11link})
statusCode
REQUIRED is a number. It is the HTTP status coderesponseTime
REQUIREDis a number. It is the latency in millisecondsresponseDataBase64
REQUIRED is a string. It is the base64 encoded response data. To use it you will have to decode it1linklet decodedResp = atob(responseDataBase64);
2link//let jsonResp = JSON.parse(decodedResp)