Skip to content
This repository was archived by the owner on Aug 7, 2026. It is now read-only.

Commit e14d5eb

Browse files
committed
Rename identifier fields in templates
1 parent 2402321 commit e14d5eb

3 files changed

Lines changed: 30 additions & 21 deletions

File tree

templates/bundle.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,91 @@
11
[
22
{
3-
"id": "simple-latency-check-for-gaming",
3+
"groupId": "simple-latency-check-for-gaming",
44
"name": "Simple Latency Check for Gaming Servers",
55
"description": "A RTT around 60ms is considered acceptable for most online gaming servers\n",
66
"variants": [
77
{
8-
"id": "simple-latency-check-for-gaming:alerting-all",
8+
"variantId": "simple-latency-check-for-gaming:alerting-all",
99
"name": "Alert to all channels if exceeds 60ms RTT",
1010
"script": "if context.error == null \u0026\u0026 context.metadata.rttMs \u003e 60 {\r\n alerting.send({\r\n header: \"Monitor [%s] notices high RTT from %s\"\r\n .format(context.monitor.name, context.location),\r\n message: \"Measured a RTT of %.2fms\\nCheck ID: %s\"\r\n .format(context.metadata.rttMs, context.check.id),\r\n footer: \"%s • Monitored by Crystade\"\r\n .format(context.team.name),\r\n deduplication: {\r\n key: context.monitor.id + \":simple-uptime-check\",\r\n ttl: \"1m\"\r\n }\r\n });\r\n}\r\n",
1111
"checksum": "aa1104d3f966ea15d513b527fa67f06245109c796b8b825bdfc3fa9974674c7c"
1212
},
1313
{
14-
"id": "simple-latency-check-for-gaming:minor-incident",
14+
"variantId": "simple-latency-check-for-gaming:minor-incident",
1515
"name": "Report minor incident if exceeds 60ms RTT",
1616
"script": "if context.error == null {\r\n if context.metadata.rttMs \u003c= 60 {\r\n incident.recover();\r\n } else {\r\n incident.signal({\r\n severity: \"minor\",\r\n title: \"Monitor [%s] notices high RTT from %s\".format(context.monitor.name, context.location),\r\n content: \"Measured a RTT of %.2fms\\nCheck ID: %s\".format(context.metadata.rttMs, context.check.id)\r\n });\r\n }\r\n}",
1717
"checksum": "35331d5cec89fbfd83d14898fb34201542ef0055f9129f670ad0ef2ca1e97d88"
1818
},
1919
{
20-
"id": "simple-latency-check-for-gaming:major-incident",
20+
"variantId": "simple-latency-check-for-gaming:major-incident",
2121
"name": "Report major incident if exceeds 60ms RTT",
2222
"script": "if context.error == null {\r\n if context.metadata.rttMs \u003c= 60 {\r\n incident.recover();\r\n } else {\r\n incident.signal({\r\n severity: \"major\",\r\n title: \"Monitor [%s] notices high RTT from %s\".format(context.monitor.name, context.location),\r\n content: \"Measured a RTT of %.2fms\\nCheck ID: %s\".format(context.metadata.rttMs, context.check.id)\r\n });\r\n }\r\n}",
2323
"checksum": "d088ad7f4f6a8f3db421cca9a2b84bf14756552426a5541c47079bd1257388d6"
2424
},
2525
{
26-
"id": "simple-latency-check-for-gaming:critical-incident",
26+
"variantId": "simple-latency-check-for-gaming:critical-incident",
2727
"name": "Report critical incident if exceeds 60ms RTT",
2828
"script": "if context.error == null {\r\n if context.metadata.rttMs \u003c= 60 {\r\n incident.recover();\r\n } else {\r\n incident.signal({\r\n severity: \"critical\",\r\n title: \"Monitor [%s] notices high RTT from %s\".format(context.monitor.name, context.location),\r\n content: \"Measured a RTT of %.2fms\\nCheck ID: %s\".format(context.metadata.rttMs, context.check.id)\r\n });\r\n }\r\n}",
2929
"checksum": "4d3e255ad717d1aad108d6cdb6c45645b1987867cc84c4ec5c4644b1eebb3cab"
3030
}
3131
]
3232
},
3333
{
34-
"id": "simple-latency-check-for-website",
34+
"groupId": "simple-latency-check-for-website",
3535
"name": "Simple Latency Check for Websites",
3636
"description": "A RTT around 100ms is considered acceptable for most websites per https://aws.amazon.com/what-is/rtt-in-networking/\n",
3737
"variants": [
3838
{
39-
"id": "simple-latency-check-for-website:alerting-all",
39+
"variantId": "simple-latency-check-for-website:alerting-all",
4040
"name": "Alert to all channels if exceeds 100ms RTT",
4141
"script": "if context.error == null \u0026\u0026 context.metadata.rttMs \u003e 100 {\r\n alerting.send({\r\n header: \"Monitor [%s] notices high RTT from %s\"\r\n .format(context.monitor.name, context.location),\r\n message: \"Measured a RTT of %.2fms\\nCheck ID: %s\"\r\n .format(context.metadata.rttMs, context.check.id),\r\n footer: \"%s • Monitored by Crystade\"\r\n .format(context.team.name),\r\n deduplication: {\r\n key: context.monitor.id + \":simple-uptime-check\",\r\n ttl: \"1m\"\r\n }\r\n });\r\n}\r\n",
4242
"checksum": "4e398d008c9c49c30fae55019ac1688512aaca57119fb203cf6fe558a368a969"
4343
},
4444
{
45-
"id": "simple-latency-check-for-website:minor-incident",
45+
"variantId": "simple-latency-check-for-website:minor-incident",
4646
"name": "Report minor incident if exceeds 100ms RTT",
4747
"script": "if context.error == null {\r\n if context.metadata.rttMs \u003c= 100 {\r\n incident.recover();\r\n } else {\r\n incident.signal({\r\n severity: \"minor\",\r\n title: \"Monitor [%s] notices high RTT from %s\".format(context.monitor.name, context.location),\r\n content: \"Measured a RTT of %.2fms\\nCheck ID: %s\".format(context.metadata.rttMs, context.check.id)\r\n });\r\n }\r\n}",
4848
"checksum": "0cf81bda06f5b14a18118d5c5ae0db95ac1f900bded34b244e6333774e555a86"
4949
},
5050
{
51-
"id": "simple-latency-check-for-website:major-incident",
51+
"variantId": "simple-latency-check-for-website:major-incident",
5252
"name": "Report major incident if exceeds 100ms RTT",
5353
"script": "if context.error == null {\r\n if context.metadata.rttMs \u003c= 100 {\r\n incident.recover();\r\n } else {\r\n incident.signal({\r\n severity: \"major\",\r\n title: \"Monitor [%s] notices high RTT from %s\".format(context.monitor.name, context.location),\r\n content: \"Measured a RTT of %.2fms\\nCheck ID: %s\".format(context.metadata.rttMs, context.check.id)\r\n });\r\n }\r\n}",
5454
"checksum": "3be24e3bd1df370a4131cee474d2798a1252308410624234791d0b6eee2f7729"
5555
},
5656
{
57-
"id": "simple-latency-check-for-website:critical-incident",
57+
"variantId": "simple-latency-check-for-website:critical-incident",
5858
"name": "Report critical incident if exceeds 100ms RTT",
5959
"script": "if context.error == null {\r\n if context.metadata.rttMs \u003c= 100 {\r\n incident.recover();\r\n } else {\r\n incident.signal({\r\n severity: \"critical\",\r\n title: \"Monitor [%s] notices high RTT from %s\".format(context.monitor.name, context.location),\r\n content: \"Measured a RTT of %.2fms\\nCheck ID: %s\".format(context.metadata.rttMs, context.check.id)\r\n });\r\n }\r\n}",
6060
"checksum": "09fc01306e3a112aa9c41a923479e825c6e9ae54f6017cb2bd115cdbc1d5f64d"
6161
}
6262
]
6363
},
6464
{
65-
"id": "simple-monitor-check",
65+
"groupId": "simple-monitor-check",
6666
"name": "Simple Monitor Check",
6767
"description": "A simple script to check for monitor status\n",
6868
"variants": [
6969
{
70-
"id": "simple-monitor-check:alerting-all",
70+
"variantId": "simple-monitor-check:alerting-all",
7171
"name": "Alert to all channels on error",
7272
"script": "if context.error != null {\r\n alerting.send({\r\n header: \"Monitor [%s] is down from %s\"\r\n .format(context.monitor.name, context.location),\r\n message: \"Got error: %s (code: %s)\\nCheck ID: %s\"\r\n .format(context.error.message, context.error.code, context.check.id),\r\n footer: \"%s • Monitored by Crystade\"\r\n .format(context.team.name),\r\n deduplication: {\r\n key: context.monitor.id + \":simple-uptime-check\",\r\n ttl: \"1m\"\r\n }\r\n });\r\n}\r\n",
7373
"checksum": "59ae4b072553ac418b4c1c6fa26824fc9980636a3eaae55e7766b237f7eda5df"
7474
},
7575
{
76-
"id": "simple-monitor-check:minor-incident",
76+
"variantId": "simple-monitor-check:minor-incident",
7777
"name": "Report minor incident on error",
7878
"script": "if context.error == null {\r\n incident.recover();\r\n} else {\r\n incident.signal({\r\n severity: \"minor\",\r\n title: \"Monitor [%s] is down from %s\".format(context.monitor.name, context.location),\r\n content: \"Got error: %s (code: %s)\\nCheck ID: %s\".format(context.error.message, context.error.code, context.check.id)\r\n });\r\n}\r\n",
7979
"checksum": "70c2b674bc2d2e4e82091123ce8466ac4e9f86c551b3fc8fc1976a86c9bc0c75"
8080
},
8181
{
82-
"id": "simple-monitor-check:major-incident",
82+
"variantId": "simple-monitor-check:major-incident",
8383
"name": "Report major incident on error",
8484
"script": "if context.error == null {\r\n incident.recover();\r\n} else {\r\n incident.signal({\r\n severity: \"major\",\r\n title: \"Monitor [%s] is down from %s\".format(context.monitor.name, context.location),\r\n content: \"Got error: %s (code: %s)\\nCheck ID: %s\".format(context.error.message, context.error.code, context.check.id)\r\n });\r\n}\r\n",
8585
"checksum": "6945ffc3ac15ccf591b3eb3b6f7c91894e85c3d2a4c0357c252e00d30744627b"
8686
},
8787
{
88-
"id": "simple-monitor-check:critical-incident",
88+
"variantId": "simple-monitor-check:critical-incident",
8989
"name": "Report critical incident on error",
9090
"script": "if context.error == null {\r\n incident.recover();\r\n} else {\r\n incident.signal({\r\n severity: \"critical\",\r\n title: \"Monitor [%s] is down from %s\".format(context.monitor.name, context.location),\r\n content: \"Got error: %s (code: %s)\\nCheck ID: %s\".format(context.error.message, context.error.code, context.check.id)\r\n });\r\n}\r\n",
9191
"checksum": "3b071196134898091b69796c88744a315fdb297cf8205b635fc75d48a3cb6991"

templates/schema.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@
88
"variants"
99
],
1010
"properties": {
11+
"groupId": {
12+
"type": "string",
13+
"description": "The template group id."
14+
},
1115
"name": {
1216
"type": "string",
13-
"description": "The template name."
17+
"description": "The template group name."
1418
},
1519
"description": {
1620
"type": "string",
17-
"description": "The template description."
21+
"description": "The template group description."
1822
},
1923
"variants": {
2024
"type": "array",
@@ -30,10 +34,15 @@
3034
"type": "object",
3135
"additionalProperties": false,
3236
"required": [
37+
"variantId",
3338
"name",
3439
"scriptFile"
3540
],
3641
"properties": {
42+
"variantId": {
43+
"type": "string",
44+
"description": "The variant id."
45+
},
3746
"name": {
3847
"type": "string",
3948
"description": "The variant name."

tools/bundle_templates.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import (
1212
)
1313

1414
type Variant struct {
15-
ID string `json:"id"`
15+
VariantID string `json:"variantId"`
1616
Name string `json:"name"`
1717
Description string `json:"description,omitempty"`
1818
Script string `json:"script"`
1919
Checksum string `json:"checksum"`
2020
}
2121

2222
type Template struct {
23-
ID string `json:"id"`
23+
GroupID string `json:"groupId"`
2424
Name string `json:"name"`
2525
Description string `json:"description,omitempty"`
2626
Variants []Variant `json:"variants"`
@@ -69,7 +69,7 @@ func main() {
6969
}
7070

7171
tmpl := Template{
72-
ID: entry.Name(),
72+
GroupID: entry.Name(),
7373
Name: manifest.Name,
7474
Description: manifest.Description,
7575
}
@@ -93,7 +93,7 @@ func main() {
9393
checksum := frontend.Checksum(tokens)
9494

9595
tmpl.Variants = append(tmpl.Variants, Variant{
96-
ID: variantID,
96+
VariantID: variantID,
9797
Name: mv.Name,
9898
Description: mv.Description,
9999
Script: string(scriptData),

0 commit comments

Comments
 (0)