From 495d399878d8ffb0634670d5977f5f18a7dfbb6d Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Sun, 13 Nov 2022 04:46:40 +0100
Subject: [PATCH] feat(mastodon): Extend mastodon SLO with response speeds

---
 apps/k8s01/mastodon/slo.yaml | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/apps/k8s01/mastodon/slo.yaml b/apps/k8s01/mastodon/slo.yaml
index c7d7c91af..1c3cc5a69 100644
--- a/apps/k8s01/mastodon/slo.yaml
+++ b/apps/k8s01/mastodon/slo.yaml
@@ -8,7 +8,7 @@ spec:
   slos:
     - name: "requests-availability"
       objective: 98
-      description: "Mastodon SLO based on availability for HTTP request responses."
+      description: "Mastodon: SLO based on availability for HTTP request responses."
       sli:
         events:
           errorQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="mastodon",ingress="mastodon",status=~"(5..|429)"}[{{.window}}]))
@@ -19,3 +19,23 @@ spec:
           category: "availability"
         annotations:
           summary: "High error rate on 'mastodon' requests responses"
+    - name: "requests-latency"
+      objective: 98
+      description: "Mastodon: SLO based on latency for HTTP request responses. Warns if requests take longer than 250ms. When responses are slower than 200ms they become noticable slow."
+      labels:
+        category: latency
+      sli:
+        events:
+          errorQuery: |
+            (
+              sum(rate(nginx_ingress_controller_request_duration_seconds_count{exported_namespace="mastodon",ingress="mastodon",method!="WATCH"}[{{.window}}]))
+              -
+              sum(rate(nginx_ingress_controller_request_duration_seconds_bucket{exported_namespace="mastodon",ingress="mastodon",le="0.25",verb!="WATCH"}[{{.window}}]))
+            )
+          totalQuery: sum(rate(nginx_ingress_controller_request_duration_seconds_count{exported_namespace="mastodon",ingress="mastodon",method!="WATCH"}[{{.window}}]))
+      alerting:
+        name: MastodonLatencyAlert
+        labels:
+          category: "latency"
+        annotations:
+          summary: "Slow responses on 'mastodon' requests responses. More than 1% take more than 250ms."
\ No newline at end of file
-- 
GitLab