Home WiFi

# This example shows the same example as home-wifi.yml but using Sloth Kubernetes CRD.
# It will generate the Prometheus rules in a Kubernetes prometheus-operator PrometheusRules CRD.
#
# `sloth generate -i ./examples/k8s-home-wifi.yml`
#
apiVersion: sloth.slok.dev/v1
kind: PrometheusServiceLevel
metadata:
  name: sloth-slo-home-wifi
  namespace: monitoring
  labels:
    prometheus: prometheus
    role: alert-rules
    app: sloth
spec:
  service: "home-wifi"
  labels:
    cluster: "valhalla"
    component: "ubiquiti"
    context: "home"
  slos:
    - name: "good-wifi-client-satisfaction"
      objective: 95
      description: "Will warn us that we don't have a good wifi at home."
      sli:
        events:
          errorQuery: sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.75))[{{.window}}:]) OR on() vector(0)
          totalQuery: sum_over_time((count(unifipoller_client_satisfaction_ratio))[{{.window}}:])
      alerting:
        name: GoodWifiClientSatisfaction
        pageAlert:
          labels:
            severity: home
        ticketAlert:
          labels:
            severity: warning

    - name: "risk-wifi-client-satisfaction"
      objective: 99.9
      description: "Will warn us that we something very bad is happenning with our home wifi."
      sli:
        events:
          errorQuery: sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.5))[{{.window}}:]) OR on() vector(0)
          totalQuery: sum_over_time((count(unifipoller_client_satisfaction_ratio))[{{.window}}:])
      alerting:
        name: RiskWifiClientSatisfaction
        pageAlert:
          labels:
            severity: home
        ticketAlert:
          labels:
            severity: warning
---
# Code generated by Sloth (dev): https://github.com/slok/sloth.
# DO NOT EDIT.

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  creationTimestamp: null
  labels:
    app: sloth
    app.kubernetes.io/component: SLO
    app.kubernetes.io/managed-by: sloth
    prometheus: prometheus
    role: alert-rules
  name: sloth-slo-home-wifi
  namespace: monitoring
spec:
  groups:
  - name: sloth-slo-sli-recordings-home-wifi-good-wifi-client-satisfaction
    rules:
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.75))[5m:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[5m:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
        sloth_window: 5m
      record: slo:sli_error:ratio_rate5m
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.75))[30m:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[30m:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
        sloth_window: 30m
      record: slo:sli_error:ratio_rate30m
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.75))[1h:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[1h:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
        sloth_window: 1h
      record: slo:sli_error:ratio_rate1h
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.75))[2h:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[2h:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
        sloth_window: 2h
      record: slo:sli_error:ratio_rate2h
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.75))[6h:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[6h:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
        sloth_window: 6h
      record: slo:sli_error:ratio_rate6h
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.75))[1d:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[1d:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
        sloth_window: 1d
      record: slo:sli_error:ratio_rate1d
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.75))[3d:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[3d:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
        sloth_window: 3d
      record: slo:sli_error:ratio_rate3d
    - expr: |
        sum_over_time(slo:sli_error:ratio_rate5m{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"}[30d])
        / ignoring (sloth_window)
        count_over_time(slo:sli_error:ratio_rate5m{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"}[30d])
      labels:
        sloth_window: 30d
      record: slo:sli_error:ratio_rate30d
  - name: sloth-slo-meta-recordings-home-wifi-good-wifi-client-satisfaction
    rules:
    - expr: vector(0.95)
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
      record: slo:objective:ratio
    - expr: vector(1-0.95)
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
      record: slo:error_budget:ratio
    - expr: vector(30)
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
      record: slo:time_period:days
    - expr: |
        slo:sli_error:ratio_rate5m{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"}
        / on(sloth_id, sloth_slo, sloth_service) group_left
        slo:error_budget:ratio{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"}
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
      record: slo:current_burn_rate:ratio
    - expr: |
        slo:sli_error:ratio_rate30d{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"}
        / on(sloth_id, sloth_slo, sloth_service) group_left
        slo:error_budget:ratio{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"}
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
      record: slo:period_burn_rate:ratio
    - expr: 1 - slo:period_burn_rate:ratio{sloth_id="home-wifi-good-wifi-client-satisfaction",
        sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"}
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
      record: slo:period_error_budget_remaining:ratio
    - expr: vector(1)
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-good-wifi-client-satisfaction
        sloth_mode: cli-gen-k8s
        sloth_objective: "95"
        sloth_service: home-wifi
        sloth_slo: good-wifi-client-satisfaction
        sloth_spec: sloth.slok.dev/v1
        sloth_version: dev
      record: sloth_slo_info
  - name: sloth-slo-alerts-home-wifi-good-wifi-client-satisfaction
    rules:
    - alert: GoodWifiClientSatisfaction
      annotations:
        summary: '{{$labels.sloth_service}} {{$labels.sloth_slo}} SLO error budget
          burn rate is over expected.'
        title: (page) {{$labels.sloth_service}} {{$labels.sloth_slo}} SLO error budget
          burn rate is too fast.
      expr: |
        (
            (slo:sli_error:ratio_rate5m{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"} > (14.4 * 0.05))
            and ignoring (sloth_window)
            (slo:sli_error:ratio_rate1h{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"} > (14.4 * 0.05))
        )
        or ignoring (sloth_window)
        (
            (slo:sli_error:ratio_rate30m{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"} > (6 * 0.05))
            and ignoring (sloth_window)
            (slo:sli_error:ratio_rate6h{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"} > (6 * 0.05))
        )
      labels:
        severity: home
        sloth_severity: page
    - alert: GoodWifiClientSatisfaction
      annotations:
        summary: '{{$labels.sloth_service}} {{$labels.sloth_slo}} SLO error budget
          burn rate is over expected.'
        title: (ticket) {{$labels.sloth_service}} {{$labels.sloth_slo}} SLO error
          budget burn rate is too fast.
      expr: |
        (
            (slo:sli_error:ratio_rate2h{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"} > (3 * 0.05))
            and ignoring (sloth_window)
            (slo:sli_error:ratio_rate1d{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"} > (3 * 0.05))
        )
        or ignoring (sloth_window)
        (
            (slo:sli_error:ratio_rate6h{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"} > (1 * 0.05))
            and ignoring (sloth_window)
            (slo:sli_error:ratio_rate3d{sloth_id="home-wifi-good-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="good-wifi-client-satisfaction"} > (1 * 0.05))
        )
      labels:
        severity: warning
        sloth_severity: ticket
  - name: sloth-slo-sli-recordings-home-wifi-risk-wifi-client-satisfaction
    rules:
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.5))[5m:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[5m:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
        sloth_window: 5m
      record: slo:sli_error:ratio_rate5m
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.5))[30m:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[30m:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
        sloth_window: 30m
      record: slo:sli_error:ratio_rate30m
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.5))[1h:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[1h:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
        sloth_window: 1h
      record: slo:sli_error:ratio_rate1h
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.5))[2h:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[2h:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
        sloth_window: 2h
      record: slo:sli_error:ratio_rate2h
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.5))[6h:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[6h:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
        sloth_window: 6h
      record: slo:sli_error:ratio_rate6h
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.5))[1d:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[1d:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
        sloth_window: 1d
      record: slo:sli_error:ratio_rate1d
    - expr: |
        (sum_over_time((count(unifipoller_client_satisfaction_ratio < 0.5))[3d:]) OR on() vector(0))
        /
        (sum_over_time((count(unifipoller_client_satisfaction_ratio))[3d:]))
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
        sloth_window: 3d
      record: slo:sli_error:ratio_rate3d
    - expr: |
        sum_over_time(slo:sli_error:ratio_rate5m{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"}[30d])
        / ignoring (sloth_window)
        count_over_time(slo:sli_error:ratio_rate5m{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"}[30d])
      labels:
        sloth_window: 30d
      record: slo:sli_error:ratio_rate30d
  - name: sloth-slo-meta-recordings-home-wifi-risk-wifi-client-satisfaction
    rules:
    - expr: vector(0.9990000000000001)
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
      record: slo:objective:ratio
    - expr: vector(1-0.9990000000000001)
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
      record: slo:error_budget:ratio
    - expr: vector(30)
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
      record: slo:time_period:days
    - expr: |
        slo:sli_error:ratio_rate5m{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"}
        / on(sloth_id, sloth_slo, sloth_service) group_left
        slo:error_budget:ratio{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"}
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
      record: slo:current_burn_rate:ratio
    - expr: |
        slo:sli_error:ratio_rate30d{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"}
        / on(sloth_id, sloth_slo, sloth_service) group_left
        slo:error_budget:ratio{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"}
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
      record: slo:period_burn_rate:ratio
    - expr: 1 - slo:period_burn_rate:ratio{sloth_id="home-wifi-risk-wifi-client-satisfaction",
        sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"}
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
      record: slo:period_error_budget_remaining:ratio
    - expr: vector(1)
      labels:
        cluster: valhalla
        cmd: examplesgen.sh
        component: ubiquiti
        context: home
        sloth_id: home-wifi-risk-wifi-client-satisfaction
        sloth_mode: cli-gen-k8s
        sloth_objective: "99.9"
        sloth_service: home-wifi
        sloth_slo: risk-wifi-client-satisfaction
        sloth_spec: sloth.slok.dev/v1
        sloth_version: dev
      record: sloth_slo_info
  - name: sloth-slo-alerts-home-wifi-risk-wifi-client-satisfaction
    rules:
    - alert: RiskWifiClientSatisfaction
      annotations:
        summary: '{{$labels.sloth_service}} {{$labels.sloth_slo}} SLO error budget
          burn rate is over expected.'
        title: (page) {{$labels.sloth_service}} {{$labels.sloth_slo}} SLO error budget
          burn rate is too fast.
      expr: |
        (
            (slo:sli_error:ratio_rate5m{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"} > (14.4 * 0.0009999999999999432))
            and ignoring (sloth_window)
            (slo:sli_error:ratio_rate1h{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"} > (14.4 * 0.0009999999999999432))
        )
        or ignoring (sloth_window)
        (
            (slo:sli_error:ratio_rate30m{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"} > (6 * 0.0009999999999999432))
            and ignoring (sloth_window)
            (slo:sli_error:ratio_rate6h{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"} > (6 * 0.0009999999999999432))
        )
      labels:
        severity: home
        sloth_severity: page
    - alert: RiskWifiClientSatisfaction
      annotations:
        summary: '{{$labels.sloth_service}} {{$labels.sloth_slo}} SLO error budget
          burn rate is over expected.'
        title: (ticket) {{$labels.sloth_service}} {{$labels.sloth_slo}} SLO error
          budget burn rate is too fast.
      expr: |
        (
            (slo:sli_error:ratio_rate2h{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"} > (3 * 0.0009999999999999432))
            and ignoring (sloth_window)
            (slo:sli_error:ratio_rate1d{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"} > (3 * 0.0009999999999999432))
        )
        or ignoring (sloth_window)
        (
            (slo:sli_error:ratio_rate6h{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"} > (1 * 0.0009999999999999432))
            and ignoring (sloth_window)
            (slo:sli_error:ratio_rate3d{sloth_id="home-wifi-risk-wifi-client-satisfaction", sloth_service="home-wifi", sloth_slo="risk-wifi-client-satisfaction"} > (1 * 0.0009999999999999432))
        )
      labels:
        severity: warning
        sloth_severity: ticket
Back to top