0

I'm trying to setup the SLO period window to 7d following the documentation https://sloth.dev/usage/slo-period-windows/

image: ghcr.io/slok/sloth:v0.11.0

When using helm (values.yaml) with and without customSloconfig enable:

sloth:
  defaultSloPeriod: 7d  # The slo period used by sloth (e.g. 30d).
customSloConfig:
  enabled: true
  path: /windows
  data: {}

It's getting error: AlertWindows.sloth.slok.dev "" not found

Directly with manifest::

apiVersion: sloth.slok.dev/v1
kind: AlertWindows
spec:
  sloPeriod: 7d
  page:
    quick:
      errorBudgetPercent: 8
      shortWindow: 5m
      longWindow: 1h
    slow:
      errorBudgetPercent: 12.5
      shortWindow: 30m
      longWindow: 6h
  ticket:
    quick:
      errorBudgetPercent: 20
      shortWindow: 2h
      longWindow: 1d
    slow:
      errorBudgetPercent: 42
      shortWindow: 6h
      longWindow: 3d
kubectl apply -f window.yaml

It's getting error:

error: resource mapping not found for name: "sloth-period-window" namespace: "" from "window.yaml": no matches for kind "AlertWindows" in version "sloth.slok.dev/v1" ensure CRDs are installed first

I tried to create CRD for AlertWindow (alertwindows.sloth.slok.dev) but no success yet. Anyone have the correct CRD for it, if this is the best way to solve it or another help, please?

It is expected that pods work with log:

INFO[0001] Hot-reload triggered from http webhook        version=v0.11.0 window=7d

1 Answers1

0

It's been resolved, if someone needs it.

using helm: set these variables as below in values.yaml

labelSelector: slo-window=7d
defaultSloPeriod: 7d

and

customSloConfig:
  enabled: true
  path: /windows
  data: 
    apiVersion: sloth.slok.dev/v1
    kind: AlertWindows
    spec:
      sloPeriod: 7d
      page:
        quick:
          errorBudgetPercent: 1
          shortWindow: 2m
          longWindow: 30m
        slow:
          errorBudgetPercent: 2
          shortWindow: 15m
          longWindow: 3h
      ticket:
        quick:
          errorBudgetPercent: 5
          shortWindow: 1h
          longWindow: 12h
        slow:
          errorBudgetPercent: 5
          shortWindow: 3h
          longWindow: 36h

I created the CRD, use it:

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: (devel)
  creationTimestamp: null
  name: alertwindows.sloth.slok.dev
spec:
  group: sloth.slok.dev
  names:
    categories:
    - saw
    kind: AlertWindows
    listKind: AlertWindowsList
    plural: alertwindows
    shortNames:
    - saw
    singular: alertwindow
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .spec.sloPeriod
      name: SLOPERIOD
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: AGE
      type: date
    name: v1
    schema:
      openAPIV3Schema:
        description: AlertWindows....
        properties:
          apiVersion:
            description: 'APIVersion defines the versioned schema of this representation
              of an object. Servers should convert recognized schemas to the latest
              internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
            type: string
          kind:
            description: 'Kind is a string value representing the REST resource this
              object represents. Servers may infer this from the endpoint the client
              submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
            type: string
          metadata:
            type: object
          spec:
            description: spec for Alert Windows.
            type: object
            properties:
              labels:
                additionalProperties:
                  type: string
                description: Labels are....
                type: object
              sloPeriod: 
                description: period.
                type: string
              page:
                description: xxx
                type: object
                properties:  
                  quick:
                    description: xxx
                    type: object
                    properties:
                      errorBudgetPercent:
                        type: integer
                      shortWindow:
                        type: string
                      longWindow:
                        type: string 
                  slow:
                    description: xxx
                    type: object
                    properties:
                      errorBudgetPercent:
                        type: number
                      shortWindow:
                        type: string
                      longWindow:
                        type: string                              
              ticket:
                description: xxx
                type: object
                properties:  
                  quick:
                    description: xxx
                    type: object
                    properties:
                      errorBudgetPercent:
                        type: integer
                      shortWindow:
                        type: string
                      longWindow:
                        type: string 
                  slow:
                    description: xxx
                    type: object
                    properties:
                      errorBudgetPercent:
                        type: integer
                      shortWindow:
                        type: string
                      longWindow:
                        type: string     
          status:
            properties:
              lastPromOpRulesSuccessfulGenerated:
                description: LastPromOpRulesGeneration tells the last atemp made for
                  a successful SLO rules generate.
                format: date-time
                type: string
              observedGeneration:
                description: ObservedGeneration tells the generation was acted on,
                  normally this is required to stop an infinite loop when the status
                  is updated because it sends a watch updated event to the watchers
                  of the K8s object.
                format: int64
                type: integer
              processedSLOs:
                description: ProcessedSLOs tells how many SLOs haven been processed
                  for Prometheus operator.
                type: integer
              promOpRulesGenerated:
                description: PromOpRulesGenerated tells if the rules for prometheus
                  operator CRD have been generated.
                type: boolean
              promOpRulesGeneratedSLOs:
                description: PromOpRulesGeneratedSLOs tells how many SLOs have been
                  processed and generated for Prometheus operator successfully.
                type: integer
            required:
            type: object
        type: object
    served: true
    storage: true
    subresources:
      status: {}

In the PrometheusServiceLevel files (SLOs) it is necessary to add this label:

  labels:
    slo-window: 7d 

Hope it helps someone.

  • Why do we need `customSloConfig` to be set in helm? Also, what is the significance of `path: /window` ? – susenj Aug 16 '23 at 07:47