Skip to content

Commit bc813e8

Browse files
committed
Add UptimeRobot plugin
1 parent baeb342 commit bc813e8

16 files changed

Lines changed: 1025 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"name": "eventLogs",
3+
"displayName": "Event Logs",
4+
"baseDataSourceName": "httpRequestScoped",
5+
"config": {
6+
"httpMethod": "post",
7+
"endpointPath": "getMonitors",
8+
"postBody": {
9+
"format": "json",
10+
"monitors": "{{objects.map((n) => n.monitorId).join('-')}}",
11+
"logs": 1
12+
},
13+
"postRequestScript": "eventLogs.js",
14+
"paging": {
15+
"mode": "offset",
16+
"pageSize": {
17+
"realm": "body",
18+
"path": "limit",
19+
"value": "50"
20+
},
21+
"offset": {
22+
"rowCountIn": {
23+
"realm": "payloadArraySize",
24+
"path": "monitors"
25+
},
26+
"mode": "row",
27+
"base": "0"
28+
},
29+
"out": {
30+
"realm": "body",
31+
"path": "offset"
32+
}
33+
}
34+
},
35+
"matches": {
36+
"sourceType": {
37+
"type": "oneOf",
38+
"values": [
39+
"UptimeRobot HTTP Monitor",
40+
"UptimeRobot Keyword Monitor",
41+
"UptimeRobot Ping Monitor",
42+
"UptimeRobot Port Monitor",
43+
"UptimeRobot Heartbeat Monitor"
44+
]
45+
}
46+
},
47+
"metadata": [
48+
{
49+
"name": "friendly_name",
50+
"displayName": "Monitor",
51+
"shape": "string",
52+
"role": "label"
53+
},
54+
{
55+
"name": "datetime",
56+
"displayName": "Timestamp",
57+
"shape": "date"
58+
},
59+
{
60+
"name": "reason.code",
61+
"displayName": "Code",
62+
"shape": "string"
63+
},
64+
{
65+
"name": "reason.detail",
66+
"displayName": "Message",
67+
"shape": "string"
68+
},
69+
{
70+
"name": "duration",
71+
"displayName": "Duration",
72+
"shape": "seconds"
73+
}
74+
]
75+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
{
2+
"name": "latestStates",
3+
"displayName": "Latest States",
4+
"baseDataSourceName": "httpRequestScoped",
5+
"config": {
6+
"httpMethod": "post",
7+
"endpointPath": "getMonitors",
8+
"postBody": {
9+
"format": "json",
10+
"monitors": "{{objects.map((n) => n.monitorId).join('-')}}"
11+
},
12+
"postRequestScript": "latestStates.js",
13+
"paging": {
14+
"mode": "offset",
15+
"pageSize": {
16+
"realm": "body",
17+
"path": "limit",
18+
"value": "50"
19+
},
20+
"offset": {
21+
"rowCountIn": {
22+
"realm": "payloadArraySize",
23+
"path": "monitors"
24+
},
25+
"mode": "row",
26+
"base": "0"
27+
},
28+
"out": {
29+
"realm": "body",
30+
"path": "offset"
31+
}
32+
}
33+
},
34+
"timeframes": false,
35+
"matches": {
36+
"sourceType": {
37+
"type": "oneOf",
38+
"values": [
39+
"UptimeRobot HTTP Monitor",
40+
"UptimeRobot Keyword Monitor",
41+
"UptimeRobot Ping Monitor",
42+
"UptimeRobot Port Monitor",
43+
"UptimeRobot Heartbeat Monitor"
44+
]
45+
}
46+
},
47+
"metadata": [
48+
{
49+
"name": "state",
50+
"displayName": "State",
51+
"shape": "state"
52+
},
53+
{
54+
"name": "friendly_name",
55+
"displayName": "Friendly Name",
56+
"visible": false,
57+
"shape": "string",
58+
"role": "label"
59+
},
60+
{
61+
"name": "link",
62+
"displayName": "Monitor",
63+
"shape": [
64+
"url",
65+
{
66+
"label": "{{column.friendly_name}}"
67+
}
68+
]
69+
},
70+
{
71+
"name": "id",
72+
"displayName": "ID",
73+
"shape": "string",
74+
"role": "id"
75+
},
76+
{
77+
"name": "status",
78+
"displayName": "Status",
79+
"shape": "string"
80+
}
81+
]
82+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "monitors",
3+
"displayName": "Monitors",
4+
"baseDataSourceName": "httpRequestUnscoped",
5+
"config": {
6+
"httpMethod": "post",
7+
"endpointPath": "getMonitors",
8+
"postBody": {
9+
"format": "json"
10+
},
11+
"postRequestScript": "monitors.js",
12+
"getArgs": [],
13+
"headers": []
14+
},
15+
"manualConfigApply": true,
16+
"matches": "none",
17+
"rowPath": [],
18+
"metadata": [],
19+
"timeframes": false
20+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"name": "responseTimes",
3+
"displayName": "Response Times",
4+
"baseDataSourceName": "httpRequestScoped",
5+
"config": {
6+
"httpMethod": "post",
7+
"endpointPath": "getMonitors",
8+
"postBody": {
9+
"format": "json",
10+
"monitors": "{{objects.map((n) => n.monitorId).join('-')}}",
11+
"response_times_end_date": "{{timeframe.unixEnd}}",
12+
"response_times_start_date": "{{timeframe.unixStart}}",
13+
"response_times": 1
14+
},
15+
"postRequestScript": "responseTimes.js",
16+
"paging": {
17+
"mode": "offset",
18+
"pageSize": {
19+
"realm": "body",
20+
"path": "limit",
21+
"value": "50"
22+
},
23+
"offset": {
24+
"rowCountIn": {
25+
"realm": "payloadArraySize",
26+
"path": "monitors"
27+
},
28+
"mode": "row",
29+
"base": "0"
30+
},
31+
"out": {
32+
"realm": "body",
33+
"path": "offset"
34+
}
35+
}
36+
},
37+
"matches": {
38+
"sourceType": {
39+
"type": "oneOf",
40+
"values": [
41+
"UptimeRobot HTTP Monitor",
42+
"UptimeRobot Keyword Monitor",
43+
"UptimeRobot Ping Monitor",
44+
"UptimeRobot Port Monitor",
45+
"UptimeRobot Heartbeat Monitor"
46+
]
47+
}
48+
},
49+
"metadata": [
50+
{
51+
"name": "friendly_name",
52+
"displayName": "Monitor",
53+
"shape": "string",
54+
"role": "label"
55+
},
56+
{
57+
"name": "datetime",
58+
"displayName": "Timestamp",
59+
"shape": "date"
60+
},
61+
{
62+
"name": "value",
63+
"displayName": "Average Response",
64+
"shape": "milliseconds",
65+
"role": "value"
66+
}
67+
]
68+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
const startTime = parseInt('{{timeframe.unixStart}}');
2+
const endTime = parseInt('{{timeframe.unixEnd}}');
3+
4+
const eventLogs = data.monitors
5+
.map((result) => {
6+
return result.logs.map((row) => ({
7+
...row,
8+
friendly_name: result.friendly_name
9+
}));
10+
})
11+
.flat()
12+
.filter((row) => row.datetime >= startTime && row.datetime <= endTime);
13+
14+
result = eventLogs;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const getType = (value) => ({
2+
1: 'UptimeRobot HTTP Monitor',
3+
2: 'UptimeRobot Keyword Monitor',
4+
3: 'UptimeRobot Ping Monitor',
5+
4: 'UptimeRobot Port Monitor',
6+
5: 'UptimeRobot Heartbeat Monitor'
7+
})[value];
8+
9+
const getStatus = (value) => ({
10+
0: 'Paused',
11+
1: 'Not Checked Yet',
12+
2: 'Up',
13+
8: 'Seems Down',
14+
9: 'Down'
15+
})[value];
16+
17+
const getState = (value) => ({
18+
0: 'unknown',
19+
1: 'unknown',
20+
2: 'success',
21+
8: 'warning',
22+
9: 'error'
23+
})[value];
24+
25+
result = data.monitors.map((result) => ({
26+
...result,
27+
id: result.id.toString(),
28+
link: `https://uptimerobot.com/dashboard?ref=website-header#${result.id}`,
29+
status: getStatus(result.status),
30+
state: getState(result.status),
31+
type: getType(result.type)
32+
}));;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const sourceName = 'UptimeRobot';
2+
3+
const type = (value) => ({
4+
1: 'UptimeRobot HTTP Monitor',
5+
2: 'UptimeRobot Keyword Monitor',
6+
3: 'UptimeRobot Ping Monitor',
7+
4: 'UptimeRobot Port Monitor',
8+
5: 'UptimeRobot Heartbeat Monitor'
9+
})[value];
10+
11+
result = data.monitors.map((monitor) => ({
12+
links: [{
13+
label: 'View in UptimeRobot',
14+
url: `https://uptimerobot.com/dashboard?ref=website-header#${monitor.id}`
15+
}],
16+
monitorUrl: monitor.url,
17+
name: monitor.friendly_name,
18+
sourceName: sourceName,
19+
sourceType: type(monitor.type),
20+
sourceId: monitor.id.toString(),
21+
monitorId: monitor.id.toString(),
22+
type: 'monitor'
23+
}));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const responseTimes = data?.monitors
2+
?.map((result) => {
3+
return result.response_times.map((row) => ({
4+
...row,
5+
friendly_name: result.friendly_name
6+
}));
7+
})
8+
.flat();
9+
10+
result = responseTimes;

0 commit comments

Comments
 (0)