From d7571ffb63bb331a67d6324fcf0ee7846f8339d5 Mon Sep 17 00:00:00 2001
From: Sheogorath <sheogorath@shivering-isles.com>
Date: Mon, 30 Oct 2023 05:10:12 +0100
Subject: [PATCH] feat(apps): Fix empty SLI metrics

---
 apps/k8s01/immich/slo.yaml   | 2 +-
 apps/k8s01/jellyfin/slo.yaml | 2 +-
 apps/k8s01/keycloak/slo.yaml | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/apps/k8s01/immich/slo.yaml b/apps/k8s01/immich/slo.yaml
index 8e10c7dcf..f497c9c00 100644
--- a/apps/k8s01/immich/slo.yaml
+++ b/apps/k8s01/immich/slo.yaml
@@ -11,7 +11,7 @@ spec:
       description: "Immich: SLO based on availability for HTTP request responses."
       sli:
         events:
-          errorQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="immich",ingress="immich",status=~"(5..|429)"}[{{.window}}]))
+          errorQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="immich",ingress="immich",status=~"(5..|429)"}[{{.window}}])) OR vector(0)
           totalQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="immich",ingress="immich"}[{{.window}}])) > 0 OR vector(1)
       alerting:
         name: ImmichHighErrorRate
diff --git a/apps/k8s01/jellyfin/slo.yaml b/apps/k8s01/jellyfin/slo.yaml
index 99edec75c..4da79cc09 100644
--- a/apps/k8s01/jellyfin/slo.yaml
+++ b/apps/k8s01/jellyfin/slo.yaml
@@ -11,7 +11,7 @@ spec:
       description: "Jellyfin: SLO based on availability for HTTP request responses."
       sli:
         events:
-          errorQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="jellyfin",ingress="jellyfin",status=~"(5..|429)"}[{{.window}}]))
+          errorQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="jellyfin",ingress="jellyfin",status=~"(5..|429)"}[{{.window}}])) OR vector(0)
           totalQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="jellyfin",ingress="jellyfin"}[{{.window}}])) > 0 OR vector(1)
       alerting:
         name: JellyfinHighErrorRate
diff --git a/apps/k8s01/keycloak/slo.yaml b/apps/k8s01/keycloak/slo.yaml
index 2dd2cfc2b..23b300029 100644
--- a/apps/k8s01/keycloak/slo.yaml
+++ b/apps/k8s01/keycloak/slo.yaml
@@ -11,7 +11,7 @@ spec:
       description: "Keycloak: SLO based on availability for HTTP request responses."
       sli:
         events:
-          errorQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="keycloak",ingress="keycloak",status=~"(5..|429)"}[{{.window}}]))
+          errorQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="keycloak",ingress="keycloak",status=~"(5..|429)"}[{{.window}}])) OR vector(0)
           totalQuery: sum(rate(nginx_ingress_controller_requests{exported_namespace="keycloak",ingress="keycloak"}[{{.window}}])) > 0 OR vector(1)
       alerting:
         name: KeycloakHighErrorRate
-- 
GitLab