@hiiretail/gcp-infra-cli 0.72.0 → 0.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/generators/resources/monitoring/append.js +49 -38
- package/generators/resources/monitoring/handle-slos.js +2 -0
- package/generators/resources/monitoring/index.js +12 -0
- package/generators/resources/monitoring/templates/slos/slos.yaml +6 -3
- package/generators/resources/monitoring/templates/slos/terragrunt.hcl +3 -2
- package/package.json +1 -1
|
@@ -10,57 +10,68 @@ const appendIncludeConfigSlo = async (fileContent, originalContentYaml, slosFile
|
|
|
10
10
|
|
|
11
11
|
const newPullArray = [];
|
|
12
12
|
|
|
13
|
+
const availabilityConf = {
|
|
14
|
+
display_name: 'Month - Availability',
|
|
15
|
+
slo_id: 'month-availability',
|
|
16
|
+
goal: 0.998,
|
|
17
|
+
calendar_period: 'MONTH',
|
|
18
|
+
type: 'windows_based_sli',
|
|
19
|
+
method: 'boolean_filter',
|
|
20
|
+
window_period: '60s',
|
|
21
|
+
};
|
|
22
|
+
|
|
13
23
|
if (inputs.sli === 'availability') {
|
|
14
|
-
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
goal: 0.998,
|
|
19
|
-
calendar_period: 'MONTH',
|
|
20
|
-
type: 'windows_based_sli',
|
|
21
|
-
method: 'boolean_filter',
|
|
22
|
-
window_period: '60s',
|
|
23
|
-
},
|
|
24
|
-
);
|
|
24
|
+
if (inputs.burnRateAlerts === 'no') {
|
|
25
|
+
availabilityConf.alert = {};
|
|
26
|
+
}
|
|
27
|
+
newPullArray.push(availabilityConf);
|
|
25
28
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
bad_service_filter:
|
|
29
|
+
|
|
30
|
+
const errorRateConf = {
|
|
31
|
+
display_name: 'Month - Error rate',
|
|
32
|
+
slo_id: 'month-error-rate',
|
|
33
|
+
goal: 0.999,
|
|
34
|
+
calendar_period: 'MONTH',
|
|
35
|
+
type: 'request_based_sli',
|
|
36
|
+
method: 'good_total_ratio',
|
|
37
|
+
bad_service_filter:
|
|
36
38
|
`metric.type="knative.dev/serving/revision/request_count"
|
|
37
39
|
resource.type="knative_revision"
|
|
38
40
|
metric.labels.response_code_class="5xx"
|
|
39
41
|
resource.labels.service_name="${inputs.serviceName}"`,
|
|
40
|
-
|
|
42
|
+
total_service_filter:
|
|
41
43
|
`metric.type="knative.dev/serving/revision/request_count"
|
|
42
44
|
resource.type="knative_revision"
|
|
43
45
|
resource.labels.service_name=${inputs.serviceName}"`,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
if (inputs.sli === 'error-rate') {
|
|
49
|
+
if (inputs.burnRateAlerts === 'no') {
|
|
50
|
+
errorRateConf.alert = {};
|
|
51
|
+
}
|
|
52
|
+
newPullArray.push(errorRateConf);
|
|
46
53
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
metric_filter:
|
|
54
|
+
|
|
55
|
+
const latencyConf = {
|
|
56
|
+
display_name: 'Month - Latency',
|
|
57
|
+
slo_id: 'month-latency',
|
|
58
|
+
goal: 0.95,
|
|
59
|
+
calendar_period: 'MONTH',
|
|
60
|
+
type: 'request_based_sli',
|
|
61
|
+
method: 'distribution_cut',
|
|
62
|
+
metric_filter:
|
|
57
63
|
`metric.type="knative.dev/serving/revision/request_latencies"
|
|
58
64
|
resource.type="knative_revision"
|
|
59
65
|
resource.labels.service_name="${inputs.serviceName}"`,
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
range_min: 0,
|
|
67
|
+
range_max: 100,
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
if (inputs.sli === 'latency') {
|
|
71
|
+
if (inputs.burnRateAlerts === 'no') {
|
|
72
|
+
latencyConf.alert = {};
|
|
73
|
+
}
|
|
74
|
+
newPullArray.push(latencyConf);
|
|
64
75
|
}
|
|
65
76
|
|
|
66
77
|
const finalYamlPullArray = yaml.dump(newPullArray);
|
|
@@ -7,6 +7,7 @@ const handleSlosFile = async (answers, slosFilePath) => {
|
|
|
7
7
|
serviceName,
|
|
8
8
|
sli,
|
|
9
9
|
systemName,
|
|
10
|
+
burnRateAlerts,
|
|
10
11
|
} = answers;
|
|
11
12
|
|
|
12
13
|
const sloFileContent = fs.readFileSync(slosFilePath, 'utf8');
|
|
@@ -16,6 +17,7 @@ const handleSlosFile = async (answers, slosFilePath) => {
|
|
|
16
17
|
serviceName,
|
|
17
18
|
sli,
|
|
18
19
|
systemName,
|
|
20
|
+
burnRateAlerts,
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
const originalContentYaml = yaml.load(sloFileContent);
|
|
@@ -53,6 +53,14 @@ module.exports = class extends BaseGenerator {
|
|
|
53
53
|
default: 'availability',
|
|
54
54
|
choices: ['availability', 'error-rate', 'latency'],
|
|
55
55
|
},
|
|
56
|
+
{
|
|
57
|
+
when: (response) => response.monitoringResource === 'slos',
|
|
58
|
+
type: 'list',
|
|
59
|
+
name: 'burnRateAlerts',
|
|
60
|
+
message: 'Please select yes if you want to create burn rate alert for the SLI',
|
|
61
|
+
default: 'yes',
|
|
62
|
+
choices: ['yes', 'no'],
|
|
63
|
+
},
|
|
56
64
|
{
|
|
57
65
|
when: (response) => response.monitoringResource === 'slos' && response.sli === 'availability',
|
|
58
66
|
type: 'confirm',
|
|
@@ -73,6 +81,7 @@ module.exports = class extends BaseGenerator {
|
|
|
73
81
|
hostname,
|
|
74
82
|
sli,
|
|
75
83
|
systemName,
|
|
84
|
+
burnRateAlerts,
|
|
76
85
|
} = this.answers;
|
|
77
86
|
|
|
78
87
|
const serviceFolderName = serviceName.replace(/ /g, '-').toLowerCase();
|
|
@@ -122,6 +131,7 @@ module.exports = class extends BaseGenerator {
|
|
|
122
131
|
monitoringResource,
|
|
123
132
|
serviceName,
|
|
124
133
|
systemName,
|
|
134
|
+
burnRateAlerts,
|
|
125
135
|
},
|
|
126
136
|
);
|
|
127
137
|
}
|
|
@@ -134,6 +144,7 @@ module.exports = class extends BaseGenerator {
|
|
|
134
144
|
monitoringResource,
|
|
135
145
|
serviceName,
|
|
136
146
|
systemName,
|
|
147
|
+
burnRateAlerts,
|
|
137
148
|
},
|
|
138
149
|
);
|
|
139
150
|
}
|
|
@@ -149,6 +160,7 @@ module.exports = class extends BaseGenerator {
|
|
|
149
160
|
serviceName,
|
|
150
161
|
systemName,
|
|
151
162
|
sli,
|
|
163
|
+
burnRateAlerts,
|
|
152
164
|
},
|
|
153
165
|
);
|
|
154
166
|
} else {
|
|
@@ -9,13 +9,15 @@
|
|
|
9
9
|
resource.type="knative_revision"
|
|
10
10
|
resource.labels.service_name="<%-serviceName%>"
|
|
11
11
|
range_min: 0
|
|
12
|
-
range_max: 100<%
|
|
12
|
+
range_max: 100<% if (burnRateAlerts === 'no') { %>
|
|
13
|
+
alert: {}<% } %><% } %><% if (sli === 'availability') { %>- display_name: Month - Availability
|
|
13
14
|
slo_id: month-availability
|
|
14
15
|
goal: 0.998
|
|
15
16
|
calendar_period: MONTH
|
|
16
17
|
type: windows_based_sli
|
|
17
18
|
method: boolean_filter
|
|
18
|
-
window_period: 60s<%
|
|
19
|
+
window_period: 60s<% if (burnRateAlerts === 'no') { %>
|
|
20
|
+
alert: {}<% } %><% } %><% if (sli === 'error-rate') { %>- display_name: Month - Error rate
|
|
19
21
|
slo_id: month-error-rate
|
|
20
22
|
goal: 0.999
|
|
21
23
|
calendar_period: MONTH
|
|
@@ -29,4 +31,5 @@
|
|
|
29
31
|
total_service_filter: |-
|
|
30
32
|
metric.type="knative.dev/serving/revision/request_count"
|
|
31
33
|
resource.type="knative_revision"
|
|
32
|
-
resource.labels.service_name="<%-serviceName%>"<%
|
|
34
|
+
resource.labels.service_name="<%-serviceName%>"<% if (burnRateAlerts === 'no') { %>
|
|
35
|
+
alert: {}<% } %><% } %>
|
|
@@ -24,8 +24,9 @@ locals {
|
|
|
24
24
|
inputs = merge(
|
|
25
25
|
local.project_vars.locals,
|
|
26
26
|
{
|
|
27
|
-
service_name
|
|
28
|
-
slos
|
|
27
|
+
service_name = "<%-systemName%>.<%-serviceName%>"
|
|
28
|
+
slos = yamldecode(file("${get_terragrunt_dir()}/slos.yaml")),
|
|
29
|
+
telemetry_resource_name = "//container.googleapis.com/projects/${local.project_vars.locals.monitoring_project_id}/locations/europe-west1/clusters/k8s-cluster/k8s/namespaces/<%-serviceName%>"
|
|
29
30
|
<% if (sli === 'availability') { %>
|
|
30
31
|
metric_filter = {
|
|
31
32
|
"metric.type" = "monitoring.googleapis.com/uptime_check/check_passed"
|