Skip to content
This repository was archived by the owner on Nov 2, 2024. It is now read-only.

Commit 20142ac

Browse files
committed
chore: add configuration schemas
add schemas describing configuration for alerts, monitoring dashboards, log-based metrics, notification channels, SLOs and uptime checks. Schemas follow JSON schema standard (draft 2020-12).
1 parent 9302a49 commit 20142ac

File tree

6 files changed

+836
-0
lines changed

6 files changed

+836
-0
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/alert.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Monitoring alert schema",
5+
"type": "object",
6+
"required": [
7+
"app-id",
8+
"version",
9+
"alerts"
10+
],
11+
"properties": {
12+
"app-id": {
13+
"type": "string",
14+
"description": "Unique identifier of the application"
15+
},
16+
"version": {
17+
"const": "0.0.1",
18+
"description": "Schema version"
19+
},
20+
"alerts": {
21+
"type": "array",
22+
"description": "A collection of alerts",
23+
"items": {
24+
"$ref": "#/$defs/alert"
25+
}
26+
}
27+
},
28+
"$defs": {
29+
"alert": {
30+
"type": "object",
31+
"description": "Alert policy",
32+
"required": [
33+
"name",
34+
"display-name",
35+
"conditions"
36+
],
37+
"properties": {
38+
"name": {
39+
"type": "string",
40+
"description": "Unique name of the dashboard resource"
41+
},
42+
"display-name": {
43+
"type": "string",
44+
"description": "A short name describing alert"
45+
},
46+
"documentation": {
47+
"type": "string",
48+
"description": "The body of the alert message. This text can be templatized using https://cloud.google.com/monitoring/alerts/doc-variables"
49+
},
50+
"combiner": {
51+
"enum": [
52+
"COMBINE_UNSPECIFIED",
53+
"AND",
54+
"OR",
55+
"AND_WITH_MATCHING_RESOURCE"
56+
],
57+
"description": "Method to combine the results of multiple conditions to determine if an incident should be opened.",
58+
"default": "AND"
59+
},
60+
"conditions": {
61+
"type": "array",
62+
"description": "A collection of policy conditions",
63+
"minItems": 1,
64+
"items": {
65+
"$ref": "#/$defs/condition"
66+
}
67+
}
68+
}
69+
},
70+
"condition": {
71+
"type": "object",
72+
"description": "A true/false test that determines when an alerting policy should open an incident",
73+
"required": [
74+
"condition"
75+
],
76+
"properties": {
77+
"display-name": {
78+
"type": "string",
79+
"description": "A short name or phrase used to identify the condition"
80+
},
81+
"condition": {
82+
"description": "Condition can be only one of the following:",
83+
"anyOf": [
84+
{
85+
"$ref": "#/$defs/conditionThreshold"
86+
},
87+
{
88+
"$ref": "#/$defs/conditionAbsent"
89+
},
90+
{
91+
"$ref": "#/$defs/conditionMatchedLog"
92+
},
93+
{
94+
"$ref": "#/$defs/conditionMonitoringQueryLanguage"
95+
}
96+
]
97+
}
98+
}
99+
},
100+
"conditionThreshold": {
101+
"type": "object",
102+
"description": "A condition that compares a collection of time series against a threshold",
103+
"required": [
104+
"filter",
105+
"threshold",
106+
"comparison"
107+
],
108+
"properties": {
109+
"filter": {
110+
"type": "string",
111+
"description": "A filter that identifies which time series should be compared with the threshold"
112+
},
113+
"threshold": {
114+
"type": "number",
115+
"describing": "A value against which to compare the time series"
116+
},
117+
"duration": {
118+
"type": "string",
119+
"description": "The amount of time that a time series must violate the threshold to be considered failing. only values that are a multiple of a minute--e.g., 0, 60, 120, or 300 seconds--are supported",
120+
"pattern": "^[0-9]+s$"
121+
},
122+
"comparison": {
123+
"enum": [
124+
"COMPARISON_LT",
125+
"COMPARISON_GT"
126+
],
127+
"description": "The comparison to apply between the time series (indicated by filter)"
128+
}
129+
}
130+
},
131+
"conditionAbsent": {},
132+
"conditionMatchedLog": {},
133+
"conditionMonitoringQueryLanguage": {}
134+
}
135+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
{
2+
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/dashboard.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Monitoring dashboard schema",
5+
"type": "object",
6+
"required": [
7+
"app-id",
8+
"version",
9+
"dashboards"
10+
],
11+
"properties": {
12+
"app-id": {
13+
"type": "string",
14+
"description": "Unique identifier of the application"
15+
},
16+
"version": {
17+
"const": "0.0.1",
18+
"description": "Schema version"
19+
},
20+
"dashboards": {
21+
"type": "array",
22+
"description": "A collection of dashboards",
23+
"items": {
24+
"$ref": "#/$defs/dashboard"
25+
}
26+
}
27+
},
28+
"$defs": {
29+
"dashboard": {
30+
"type": "object",
31+
"description": "Monitoring dashboard properties",
32+
"required": [
33+
"name",
34+
"display-name",
35+
"widgets"
36+
],
37+
"properties": {
38+
"name": {
39+
"type": "string",
40+
"description": "Unique name of the dashboard resource"
41+
},
42+
"display-name": {
43+
"type": "string",
44+
"description": "Human friendly name of dashboard to be displayed in Cloud Console"
45+
},
46+
"widgets": {
47+
"type": "array",
48+
"description": "A collection of dashboard's widgets",
49+
"items": {
50+
"$ref": "#/$defs/widget"
51+
}
52+
}
53+
}
54+
},
55+
"widget": {
56+
"type": "object",
57+
"description": "A chart that displays data on a 2D (X and Y axes) plane (https://cloud.google.com/monitoring/api/ref_v3/rest/v1/projects.dashboards#xychart)",
58+
"required": [
59+
"datasets"
60+
],
61+
"properties": {
62+
"title": {
63+
"type": "string",
64+
"description": "Human friendly name of widget"
65+
},
66+
"x-axis-label": {
67+
"type": "string",
68+
"description": "Human friendly label of axis X"
69+
},
70+
"y-axis-label": {
71+
"type": "string",
72+
"description": "Human friendly label of axis Y"
73+
},
74+
"datasets": {
75+
"type": "array",
76+
"description": "The data displayed in this chart.",
77+
"minItems": 1,
78+
"items": {
79+
"$ref": "#/$defs/dataset"
80+
}
81+
}
82+
}
83+
},
84+
"dataset": {
85+
"type": "object",
86+
"description": "Groups a time series query definition with charting options (https://cloud.google.com/monitoring/api/ref_v3/rest/v1/projects.dashboards#dataset)",
87+
"required": [
88+
"time-series"
89+
],
90+
"properties": {
91+
"time-series": {
92+
"type": "object",
93+
"description": "A set of parameters for querying time series data",
94+
"required": [
95+
"filter"
96+
],
97+
"properties": {
98+
"filter": {
99+
"query": {
100+
"type": "string",
101+
"description": "Identifies the metric types, resources, and projects to query"
102+
},
103+
"alignment": {
104+
"enum": [
105+
"ALIGN_NONE",
106+
"ALIGN_DELTA",
107+
"ALIGN_RATE",
108+
"ALIGN_INTERPOLATE",
109+
"ALIGN_NEXT_OLDER",
110+
"ALIGN_MIN",
111+
"ALIGN_MAX",
112+
"ALIGN_MEAN",
113+
"ALIGN_COUNT",
114+
"ALIGN_SUM",
115+
"ALIGN_STDDEV",
116+
"ALIGN_COUNT_TRUE",
117+
"ALIGN_COUNT_FALSE",
118+
"ALIGN_FRACTION_TRUE",
119+
"ALIGN_PERCENTILE_99",
120+
"ALIGN_PERCENTILE_95",
121+
"ALIGN_PERCENTILE_50",
122+
"ALIGN_PERCENTILE_05",
123+
"ALIGN_PERCENT_CHANGE"
124+
],
125+
"description": "Mathematical method to group data points together into a single time series",
126+
"default": "ALIGN_MEAN"
127+
}
128+
},
129+
"unit-override": {
130+
"type": "string",
131+
"description": "Label for unit of data contained in fetched time series",
132+
"default": "1"
133+
}
134+
}
135+
},
136+
"min-alignment-period": {
137+
"type": "string",
138+
"description": "The lower bound on data point frequency for this data set",
139+
"pattern": "^[0-9]+(s|m|h)?$"
140+
}
141+
}
142+
}
143+
}
144+
}
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"$id": "https://github.com/GoogleCloudPlatform/cloud-ops-sandbox/provisioning/schemas/log_based_metric.json",
3+
"$schema": "https://json-schema.org/draft/2020-12/schema",
4+
"title": "Log-based metric schema",
5+
"type": "object",
6+
"required": [
7+
"app-id",
8+
"version",
9+
"log-based-metrics"
10+
],
11+
"properties": {
12+
"app-id": {
13+
"type": "string",
14+
"description": "Unique identifier of the application"
15+
},
16+
"version": {
17+
"const": "0.0.1",
18+
"description": "Schema version"
19+
},
20+
"log-based-metrics": {
21+
"type": "array",
22+
"description": "A collection of log-based metric",
23+
"items": {
24+
"$ref": "#/$defs/log-based-metric"
25+
}
26+
}
27+
},
28+
"$defs": {
29+
"log-based-metric": {
30+
"type": "object",
31+
"description": "Describes a logs-based metric",
32+
"required": [
33+
"name",
34+
"filter"
35+
],
36+
"properties": {
37+
"name": {
38+
"type": "string",
39+
"description": "A metric identifier",
40+
"pattern": "^[A-Za-z0-9_\\-]+$",
41+
"maxLength": 100
42+
},
43+
"description": {
44+
"type": "string",
45+
"description": "A description of this metric, which is used in documentation",
46+
"maxLength": 8000
47+
},
48+
"filter": {
49+
"type": "string",
50+
"description": "A logs filter which is used to match log entries (https://cloud.google.com/logging/docs/view/advanced_filters)"
51+
},
52+
"bucket-name": {
53+
"type": "string",
54+
"description": "A fully qualified resource name of the Log Bucket that owns the Log Metric. The bucket has to be in the same project as the metric"
55+
},
56+
"metric-descriptor": {
57+
"type": "object",
58+
"description": "A metric descriptor associated with the logs-based metric. If unspecified, it uses a default metric descriptor with a DELTA metric kind, INT64 value type, with no labels and a unit of '1'",
59+
"properties": {
60+
"kind": {
61+
"const": "DELTA",
62+
"description": "Fixed way to report data"
63+
},
64+
"value-type": {
65+
"enum": [
66+
"INT64",
67+
"DISTRIBUTION"
68+
],
69+
"description": "Types of the reported metric supported for log based metrics",
70+
"default": "INT64"
71+
},
72+
"unit": {
73+
"const": "1",
74+
"description": "Fixed as dimensionless"
75+
}
76+
}
77+
},
78+
"extractor": {
79+
"type": "string",
80+
"description": "Method to extract metric values for distribution value type of the metric (https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics#LogMetric.FIELDS.value_extractor)"
81+
},
82+
"labels": {
83+
"type": "array",
84+
"description": "Collection of labels extracted together with the metric",
85+
"items": {
86+
"$ref": "#/$defs/metric-label"
87+
}
88+
}
89+
}
90+
},
91+
"metric-label": {
92+
"type": "object",
93+
"description": "A pair of label key and extractor expression to load label's value from logs",
94+
"required": [
95+
"key",
96+
"extractor"
97+
],
98+
"properties": {
99+
"key": {
100+
"type": "string",
101+
"description": "Unique label description",
102+
"pattern": "^[a-z_\\-]+$"
103+
},
104+
"description": {
105+
"type": "string",
106+
"description": "A human-readable description for the label"
107+
},
108+
"extractor": {
109+
"type": "string",
110+
"description": "Same as #/$defs/log-based-metric/extractor"
111+
}
112+
}
113+
}
114+
}
115+
}

0 commit comments

Comments
 (0)