kolonialno / sloth

🦥 Easy and simple Prometheus SLO (service level objectives) generator
https://sloth.dev
Apache License 2.0
3 stars 1 forks source link

Using denominator_corrected gives error 'sli_type_required' #8

Closed nicholas-russell closed 10 months ago

nicholas-russell commented 11 months ago

I am trying to use the denominator_corrected SLI type, but am getting an error sli_type_required.

I have a file test.yaml looks like this:

version: "prometheus/v1"
service: "my-service"
labels:
  env: "prod"
slos:
  - name: "requests-availability"
    objective: 99
    description: "Common SLO based on availability."
    sli:
      denominator_corrected:
        errorQuery: sum(rate(http_requests_total{status_code=~"(5..|429)"}[{{.window}}]))
        totalQuery: sum(rate(http_requests_total{}[{{.window}}]))
    alerting:
      name: AvailabilityAlert
      labels:
        category: "availability"
      page_alert:
        labels:
          severity: critical
      ticket_alert:
        labels:
          severity: warning

Trying to generate the rules gives this error:

$ sloth-cli --debug generate -i test.yaml
DEBU[0000] Debug level is enabled                        version=v0.14.0
INFO[0000] SLI plugins loaded                            plugins=0 svc=storage.FileSLIPlugin version=v0.14.0 window=30d
INFO[0000] SLO period windows loaded                     svc=alert.WindowsRepo version=v0.14.0 window=30d windows=2
INFO[0000] Generating from Prometheus spec               version=v0.14.0 window=30d
error: "generate" command failed: could not generate Prometheus format rules: could not generate prometheus rules: invalid SLO group: Key: 'SLOGroup.SLOs[0].SLI.' Error:Field validation for '' failed on the 'sli_type_required' tag

I was following the diff in https://github.com/slok/sloth/pull/459, but I feel like I may be missing something.

gbbirkisson commented 10 months ago

Yup, this was a bug. Fixed in the latest release: https://github.com/kolonialno/sloth/releases/tag/v0.14.1