-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add Cloud Monitoring MQL backend (#245)
* ignore virtual environments like venv3.9.12 too * bump google-cloud-monitoring to v2 and migrate code * remove redundant parentheses * fix typo * remove unused argument in docstring * fix mutable default arguments * add `make uninstall` target to uninstall all pip packages * fix wrong migration of field names * disable Pylint warnings for fields that do exist * add type hints * add Cloud Monitoring MQL samples * reformat for flake8 * aggregate (sum) time series before computing their ratio * annotate and clean up distribution_cut() * add private method to format MQL query + tests * disable warnings for known unused arguments * fix syntax error * disable flake8 checks in tests (for trailing whitespaces for example) * fix type hints for dict.get() operations * make type hints and pylint warnings compatible with python < 3.9
- Loading branch information
Showing
16 changed files
with
658 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,6 @@ htmlcov/ | |
*.tfstate.*.backup | ||
.vscode | ||
.env | ||
venv/ | ||
.venv/ | ||
venv*/ | ||
.venv*/ | ||
reports/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
samples/cloud_monitoring_mql/slo_gae_app_availability.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
apiVersion: sre.google.com/v2 | ||
kind: ServiceLevelObjective | ||
metadata: | ||
name: gae-app-availability | ||
labels: | ||
service_name: gae | ||
feature_name: app | ||
slo_name: availability | ||
spec: | ||
description: Availability of App Engine app | ||
backend: cloud_monitoring_mql | ||
method: good_bad_ratio | ||
exporters: | ||
- cloud_monitoring | ||
service_level_indicator: | ||
filter_good: > | ||
fetch gae_app | ||
| metric 'appengine.googleapis.com/http/server/response_count' | ||
| filter resource.project_id == '${GAE_PROJECT_ID}' | ||
| filter | ||
metric.response_code == 429 | ||
|| metric.response_code == 200 | ||
|| metric.response_code == 201 | ||
|| metric.response_code == 202 | ||
|| metric.response_code == 203 | ||
|| metric.response_code == 204 | ||
|| metric.response_code == 205 | ||
|| metric.response_code == 206 | ||
|| metric.response_code == 207 | ||
|| metric.response_code == 208 | ||
|| metric.response_code == 226 | ||
|| metric.response_code == 304 | ||
filter_valid: > | ||
fetch gae_app | ||
| metric 'appengine.googleapis.com/http/server/response_count' | ||
| filter resource.project_id == '${GAE_PROJECT_ID}' | ||
goal: 0.95 |
36 changes: 36 additions & 0 deletions
36
samples/cloud_monitoring_mql/slo_gae_app_availability_ratio.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apiVersion: sre.google.com/v2 | ||
kind: ServiceLevelObjective | ||
metadata: | ||
name: gae-app-availability | ||
labels: | ||
service_name: gae | ||
feature_name: app | ||
slo_name: availability | ||
spec: | ||
description: Availability of App Engine app | ||
backend: cloud_monitoring_mql | ||
method: query_sli | ||
exporters: | ||
- cloud_monitoring | ||
service_level_indicator: | ||
query: > | ||
fetch gae_app | ||
| metric 'appengine.googleapis.com/http/server/response_count' | ||
| filter resource.project_id == '${GAE_PROJECT_ID}' | ||
| { filter | ||
metric.response_code == 429 | ||
|| metric.response_code == 200 | ||
|| metric.response_code == 201 | ||
|| metric.response_code == 202 | ||
|| metric.response_code == 203 | ||
|| metric.response_code == 204 | ||
|| metric.response_code == 205 | ||
|| metric.response_code == 206 | ||
|| metric.response_code == 207 | ||
|| metric.response_code == 208 | ||
|| metric.response_code == 226 | ||
|| metric.response_code == 304 | ||
; ident } | ||
| sum | ||
| ratio | ||
goal: 0.95 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2019 Google Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
--- | ||
apiVersion: sre.google.com/v2 | ||
kind: ServiceLevelObjective | ||
metadata: | ||
name: gae-app-latency724ms | ||
labels: | ||
service_name: gae | ||
feature_name: app | ||
slo_name: latency724ms | ||
spec: | ||
description: Latency of App Engine app requests < 724ms | ||
backend: cloud_monitoring_mql | ||
method: distribution_cut | ||
exporters: | ||
- cloud_monitoring | ||
service_level_indicator: | ||
filter_valid: > | ||
fetch gae_app | ||
| metric 'appengine.googleapis.com/http/server/response_latencies' | ||
| filter resource.project_id == '${GAE_PROJECT_ID}' | ||
| filter | ||
metric.response_code >= 200 | ||
&& metric.response_code < 500 | ||
good_below_threshold: true | ||
threshold_bucket: 19 | ||
goal: 0.999 |
28 changes: 28 additions & 0 deletions
28
samples/cloud_monitoring_mql/slo_lb_request_availability.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
apiVersion: sre.google.com/v2 | ||
kind: ServiceLevelObjective | ||
metadata: | ||
name: lb-request-availability | ||
labels: | ||
service_name: lb | ||
feature_name: request | ||
slo_name: availability | ||
spec: | ||
description: Availability of HTTP Load Balancer | ||
backend: cloud_monitoring_mql | ||
method: good_bad_ratio | ||
exporters: | ||
- cloud_monitoring | ||
service_level_indicator: | ||
filter_good: > | ||
fetch 'https_lb_rule' | ||
| metric 'loadbalancing.googleapis.com/https/request_count' | ||
| filter resource.project_id == '${LB_PROJECT_ID}' | ||
| filter | ||
metric.response_code_class="200" | ||
|| metric.response_code_class="300" | ||
|| metric.response_code_class="400" | ||
filter_valid: > | ||
fetch 'https_lb_rule' | ||
| metric 'loadbalancing.googleapis.com/https/request_count' | ||
| filter resource.project_id == '${LB_PROJECT_ID}' | ||
goal: 0.98 |
27 changes: 27 additions & 0 deletions
27
samples/cloud_monitoring_mql/slo_lb_request_availability_ratio.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apiVersion: sre.google.com/v2 | ||
kind: ServiceLevelObjective | ||
metadata: | ||
name: lb-request-availability | ||
labels: | ||
service_name: lb | ||
feature_name: request | ||
slo_name: availability | ||
spec: | ||
description: Availability of HTTP Load Balancer | ||
backend: cloud_monitoring_mql | ||
method: query_sli | ||
exporters: | ||
- cloud_monitoring | ||
service_level_indicator: | ||
query: > | ||
fetch 'https_lb_rule' | ||
| metric 'loadbalancing.googleapis.com/https/request_count' | ||
| filter resource.project_id == '${LB_PROJECT_ID}' | ||
| { filter | ||
metric.response_code_class="200" | ||
|| metric.response_code_class="300" | ||
|| metric.response_code_class="400" | ||
; ident } | ||
| sum | ||
| ratio | ||
goal: 0.98 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
apiVersion: sre.google.com/v2 | ||
kind: ServiceLevelObjective | ||
metadata: | ||
name: lb-request-latency724ms | ||
labels: | ||
service_name: lb | ||
feature_name: request | ||
slo_name: latency724ms | ||
spec: | ||
description: Latency of HTTP Load Balancer < 724ms | ||
backend: cloud_monitoring_mql | ||
method: distribution_cut | ||
exporters: | ||
- cloud_monitoring | ||
service_level_indicator: | ||
filter_valid: > | ||
fetch https_lb_rule | ||
| metric 'loadbalancing.googleapis.com/https/total_latencies' | ||
| filter resource.project_id == '${LB_PROJECT_ID}' | ||
| filter metric.label.response_code_class = "200" | ||
|| metric.response_code_class = "300" | ||
|| metric.response_code_class = "400" | ||
good_below_threshold: true | ||
threshold_bucket: 19 | ||
goal: 0.98 |
24 changes: 24 additions & 0 deletions
24
samples/cloud_monitoring_mql/slo_pubsub_subscription_throughput.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: sre.google.com/v2 | ||
kind: ServiceLevelObjective | ||
metadata: | ||
name: pubsub-subscription-throughput | ||
labels: | ||
service_name: pubsub | ||
feature_name: subscription | ||
slo_name: throughput | ||
spec: | ||
description: Throughput of Pub/Sub subscription | ||
backend: cloud_monitoring_mql | ||
method: good_bad_ratio | ||
exporters: | ||
- cloud_monitoring | ||
service_level_indicator: | ||
filter_good: > | ||
fetch 'pubsub_subscription' | ||
| metric 'pubsub.googleapis.com/subscription/ack_message_count' | ||
| filter resource.project_id == '${PUBSUB_PROJECT_ID}' | ||
filter_bad: > | ||
fetch 'pubsub_subscription' | ||
| metric 'pubsub.googleapis.com/subscription/num_outstanding_messages' | ||
| filter resource.project_id == '${PUBSUB_PROJECT_ID}' | ||
goal: 0.95 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.