slok / sloth

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

OpenSLOs won't validate #496

Open kaosmonk opened 1 year ago

kaosmonk commented 1 year ago

Hi team,

I am trying to generate some prometheus rules based on OpenSLO specification but even though my yaml is slightly different from the one provided by you, I am getting the following error:

error: "generate" command failed: could not generate OpenSLO format rules: could not generate prometheus rules: invalid SLO group: Key: 'SLOGroup.SLOs[0].SLI.Raw.ErrorRatioQuery' Error:Field validation for 'ErrorRatioQuery' failed on the 'template_vars' tag%

The yaml against which I am running sloth generate is as follows:

apiVersion: openslo/v1alpha
kind: SLO
metadata:
  name: pri-disk
  displayName: "SAP HANA volume free space size"
spec:
  service: hana
  description: "Common SLO based on volume free space size"
  budgetingMethod: Timeslices
  objectives:
    - ratioMetrics:
        good:
          source: prometheus
          queryType: promql
          query: "(sum(hana_disk_total_size_mb{instance='pri',path='/data/HA0'}) - sum(hanadb_disk_used_size_mb{instance='pri',path='/data/HA0/'}))"
        total:
          source: prometheus
          queryType: promql
          query: "sum(hanadb_disk_total_size_mb{instance='pri',path='/data/HA0/'})"
      target: 0.25
  timeWindows:
    - count: 1
      unit: Day

What am I doing wrong? I am not even using a Raw ratio as one can see in the example above.

r3code commented 1 year ago

Did you validate this spec with oslo?

kaosmonk commented 1 year ago

Yes, am able to validate the above specs with oslo.