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

Prometheus rule created but not loaded on prometheus operator #125

Closed
stafot opened this issue Jul 20, 2021 · 4 comments
Closed

Prometheus rule created but not loaded on prometheus operator #125

stafot opened this issue Jul 20, 2021 · 4 comments
Labels
kubernetes question Further information is requested

Comments

@stafot
Copy link

stafot commented Jul 20, 2021

Hello,
I am not sure if this is a bug or I am missing something in setup process.

I am trying to setup sloth on my cluster based on this approach https://github.com/slok/sloth#kubernetes-controller-prometheus-operator.
I successfully set up the sloth controller which runs without any errors.
I added a sample slo for a service running. The respective prometheus rule created successfully. But the rule doesn't get attached to prometheus operator. Should I do it manually? If yes why not to follow the cli approach instead?

Thanks in advance for any answer.

@slok slok added kubernetes question Further information is requested labels Jul 20, 2021
@slok
Copy link
Owner

slok commented Jul 20, 2021

Hi @stafot

Once the Prometheus operator Rules CRs are created, Sloth's job finishes, and you shouldn't need to do anything manually either.

Are you already loading automatically any other rules (apart from the Sloth ones) with the Prometheus operator?

Normally when you create a Prometheus instance with the Prom-operator, you will tell what is the label selector this Prometheus needs to match to discover the rules it should own (and load), if you don't have this configured correctly it will not discover the created rules. For example:

apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  name: prometheus
  namespace: monitoring
  labels:
    prometheus: prometheus
spec:
# ...
  ruleSelector:
    matchLabels:
      prometheus: prometheus
      role: my-awesome-rules
# ...

Now my PrometheusRules CRs at least should have prometheus: prometheus and role: my-awesome-rules labels so this prom can load them automatically. Sloth will set the same labels the Sloth CRs has to the PrometheusRule CR, so, for example:

---
apiVersion: sloth.slok.dev/v1
kind: PrometheusServiceLevel
metadata:
  name: some-slo
  namespace: monitoring
  labels:
    prometheus: prometheus
    role: my-awesome-rules
    app: sloth
    something: something
spec:
# ...

Let me know if this solves the problem.

@stafot
Copy link
Author

stafot commented Jul 20, 2021

Thanks for your quick answer. I will review my setup based on your instructions and I will come back to you! Appreciated.

@stafot
Copy link
Author

stafot commented Jul 20, 2021

@slok Thank you very much, your suggestion did the trick.

@stafot stafot closed this as completed Jul 20, 2021
@slok
Copy link
Owner

slok commented Jul 20, 2021

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kubernetes question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants