-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
How to add multiple ServiceMonitor to PrometheusOperator object #3996
Comments
Yes, that is how label matches work in kubernetes. Solution is to use another label in ServiceMonitors (we most commonly use |
Thanks for the response @paulfantom
Let me know if I am wrong but this means creating two prometheus-main object with each concentrating on different service monitor. For example:
|
No. Solution is to use different labels, adding another Use one selector in Prometheus object, like:
and use Additionally, if you have only one Prometheus server and wish for this server to collect metrics from all ServiceMonitors in the cluster, then just use |
This issue has been automatically marked as stale because it has not had any activity in the last 60 days. Thank you for your contributions. |
This issue was closed because it has not had any activity in the last 120 days. Please reopen if you feel this is still valid. |
@paulfantom Hello brother, I would like to ask a question, how to determine whether the data is collected after the ServiceMonitor is configured? I can't search on prometheus /graph |
@gr8Adakron : Did you make it work? I am in a same situation, I tried:
|
Sorry, I haven't followed up on github recently, my issue has been resolved, thank you. |
The only way to have multiple targets 'ORed' is to use To answer the original question you could have serviceMonitorSelector:
matchExpressions:
- key: app
operator: In
values:
- frontend
- backend Or, if you're running serviceMonitorSelector:
# Default value:
# matchLabels:
# release: kube-prometheus-stack
matchExpressions:
- key: release
operator: In
values:
- kube-prometheus-stack
- frontend-app
- backend-app |
What did you do?
I have configured prometheus operator with 2 service monitors:
My service monitors files
Now I am refering the service monitor in the
prometheus-main-object
(Note: below YAML contain just issue-relevant field)How do I add
app: backend
as well to the main object, I try doing like this:But this didnt work as matchLabels works as
AND
operator.Any help is appreaciated. THanks
The text was updated successfully, but these errors were encountered: