Skip to content

Commit 8f52c39

Browse files
committed
feat: add SLO definition [no ci]
1 parent 98cbbe2 commit 8f52c39

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Resources/gcp/api_v2_slo.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
# Execute in cloud shell
3+
ACCESS_TOKEN=$(gcloud auth print-access-token)
4+
CREATE_SLO_POST_BODY=$(cat <<EOF
5+
{
6+
"displayName": "99% - Good/Bad Ratio - Rolling 30 days",
7+
"goal": 0.99,
8+
"rollingPeriod": "86400s",
9+
"serviceLevelIndicator": {
10+
"requestBased": {
11+
"goodTotalRatio": {
12+
"goodServiceFilter": "metric.type=\"logging.googleapis.com/user/200-functions\" resource.type=\"cloud_function\"",
13+
"badServiceFilter": "metric.type=\"logging.googleapis.com/user/errored-functions\" resource.type=\"cloud_function\""
14+
}
15+
}
16+
}
17+
}
18+
EOF
19+
)
20+
21+
curl --http1.1 --header "Authorization: Bearer $ACCESS_TOKEN" --header "Content-Type: application/json" -X POST -d "$CREATE_SLO_POST_BODY" "https://monitoring.googleapis.com/v3/projects/$GOOGLE_CLOUD_PROJECT/services/_1QdRovaRBGqDhnMI8i2Yw/serviceLevelObjectives"

0 commit comments

Comments
 (0)