Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for time_slice slo #313

Closed
wants to merge 4 commits into from

Conversation

kaarolch
Copy link
Contributor

Add suport for time_slice SLO, that instead query use sliSpecification:

sli_specification {
    time_slice {
      query {
        formula {
          formula_expression = "query1"
        }
        query {
          metric_query {
            name  = "query1"
            query = "avg:my.custom.count.metric{*}.as_count()"
          }
        }
      }
      comparator = ">"
      threshold  = 0.9
    }

I'm a beginner at Ruby, so if some of my code isn't well-written, I would appreciate feedback.

Checklist

  • Verified against local install of kennel (using path: in Gemfile)
  • Added tests
  • Updated Readme.md (if user facing behavior changed)

lib/kennel/models/slo.rb Outdated Show resolved Hide resolved
lib/kennel/models/slo.rb Outdated Show resolved Hide resolved
Copy link
Owner

@grosser grosser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the importer needs to support it too

@grosser
Copy link
Owner

grosser commented May 23, 2024

looks mostly right, thx for the PR
I can pair on this next week if you are getting stuck or spending >30m on this 👍

@kaarolch
Copy link
Contributor Author

I will try to update imported this week / Mon. Thank for review and hints 👍

@kaarolch
Copy link
Contributor Author

kaarolch commented May 24, 2024

@grosser added sli_specification to importer, but still need to fix nesting conversion in sli_specification.

@@ -19,10 +19,15 @@ def import(resource, id)
raise(ArgumentError, "#{resource} is not supported")

data = @api.show(model.api_resource, id)
# get sli specification before normalization.
sli_specification = data[:sli_specification] || data.dig(:sli_specification, :time_slice)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can it be in 2 different places ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... fixed this, we had some temp-fix code that added it to read-only :D

@@ -35,7 +35,9 @@ def build_json
type: type
)

if v = query
if type == 'time_slice'
data[:sliSpecification] = :sli_specification
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs to be the actual call ?

Suggested change
data[:sliSpecification] = :sli_specification
data[:sliSpecification] = sli_specification

@grosser
Copy link
Owner

grosser commented May 25, 2024

fixing here #314

@grosser grosser closed this May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants