-
Notifications
You must be signed in to change notification settings - Fork 110
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
Standalone cli tool able to transform SLO definitions into prom rules #314
Comments
Hey. Excellent idea. In the end this tool doesn't even need to be standalone. We can put that functionality into the pyrra binary itself. I'd start by adding a new sub command next to the existing ones called Lines 113 to 114 in 3a58b4e
The first argument would be a relative file path that needs to be loaded and unmarshalled: Lines 158 to 203 in 3a58b4e
This should be a lot of similar code that can be reused, probably even be refactored into a function such that both filesystem and generate can use the same code.
PS: For a year now, I wanted to finally rewrite promtools.dev to use the same Pyrra generator rather than the previous slo-libsonnet... Hopefully I get to that one day, so that the website is equally helpful. |
Hey @ArthurSens , sorry didn't notice you've already opened the PR for that because that was in my drafts for about a week. I can close mine because our implementations are quite similar. |
Heeey, funny how we came up with the same solution 🤣. Since we both did the same thing, I don't mind which PR is merged... |
This looks very interesting for a similar use-case we have with a dedicated prometheus server. Would #361 result in a dedicated binary that we could use in Ansible playbooks? Just to clarify, this is our use-case. We have OpenShift with a Prometheus server outside of the cluster looking in. We used the example in #219 to depoly Pyrra in OpenShift with some minor tweaks to namespace and resource specs. Prometheus is unable to pick up the recording and alerting rules since they exist inside the cluster and are expected to be picked up by a prometheus-operator. The alternative of creating a configmap doesn't change this as we need to get the configmaps onto the Prometheus server under the expected rules folder and trigger a configuration reload. If #361 results in a dedicated binary then we could create a playbook with ansible to generate the files based of the |
Hey, it is not a whole new CLI. It is the same It has been years since I tried Ansible playbooks so I can't tell if it works with Ansible or not, but you can test the binary yourself by running:
You can run |
Thanks, worked great! Only one issue, doesn't seem to handle more than one entry per yaml-file. Tried putting 3 SLO-entries in the same yaml-file and only the first entry was generated. If I split it up into 3 separate files and run the command with a wildcard to target all 3 files then it works fine. Example with all 3 entries in one file below: ---
apiVersion: pyrra.dev/v1alpha1
kind: ServiceLevelObjective
metadata:
name: prometheus-operator-http
namespace: pyrra
labels:
prometheus: k8s
role: alert-rules
spec:
target: '95.0'
window: 7d
indicator:
ratio:
errors:
metric: prometheus_operator_kubernetes_client_http_requests_total{status_code=~"5.."}
total:
metric: prometheus_operator_kubernetes_client_http_requests_total
---
apiVersion: pyrra.dev/v1alpha1
kind: ServiceLevelObjective
metadata:
labels:
prometheus: k8s
role: alert-rules
name: apiserver-read-response-errors
namespace: pyrra
spec:
description: ""
indicator:
ratio:
errors:
metric: apiserver_request_total{job="apiserver",verb=~"LIST|GET",code=~"5.."}
total:
metric: apiserver_request_total{job="apiserver",verb=~"LIST|GET"}
target: "99.99"
window: 2w
---
apiVersion: pyrra.dev/v1alpha1
kind: ServiceLevelObjective
metadata:
labels:
prometheus: k8s
role: alert-rules
name: apiserver-write-response-errors
namespace: pyrra
spec:
description: ""
indicator:
ratio:
errors:
metric: apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE",code=~"5.."}
total:
metric: apiserver_request_total{job="apiserver",verb=~"POST|PUT|PATCH|DELETE"}
target: "99"
window: 1w |
We're evaluating using a SaaS service for prometheus and just noticed how this issue would be useful for this scenario. Using a SaaS service for metrics storage and rule evaluation makes us unable to use prometheus-operator's PromRule CRD. If pyrra can be used as a CLI to transform SLO definitions into rule files, we can use CI to upload the rule definitions into the SaaS offering. Pyrra UI would query this same SaaS, where the recording rules are being evaluated 🙂 |
Sounds like a plan, yes! |
I'd like to be able to use pyrra's functionality in an environment that does not match how pyrra is supposed to be deployed. To that end I'm interested in the following feature: a build of (parts of) pyrra as a standalone CLI binary capable (at least initially) of transforming files containing SLO definitions into files containing prom rules.
Example usage:
pyrratool slo2prom -i slo.yaml -o promrules.yaml
The text was updated successfully, but these errors were encountered: