First, make sure it’s actually not showing up:
- Check
prometheus-operator
logs to verify if there is something abnormal happening - Go to prometheus UI
/service-discovery
and check if your service is present there. If it is thenServiceMonitor
was picked up, the issue is with incorrectly selected port in endpoints field. - If your
ServiceMonitor
is not registered in/service-discovery
then check what is the value ofserviceMonitorSelector
field in your Prometheus object and adjustingServiceMonitor
labels accordingly. Value of {} selects all serviceMonitors. See bellow for command. - If you still don’t have
ServiceMonitor
registered, check a fieldserviceMonitorNamespaceSelector
to verify if prometheus should look for serviceMonitor in that namespace. Value of{}
selects all namespaces. - If after waiting 15 minutes you still don’t have your
ServiceMonitor
registered, check RBAC.
You can easily check the values set for the serviceMonitorSelector
in your Prometheus Deployment:
kubectl get prometheuses.monitoring.coreos.com --all-namespaces -o jsonpath="{.items[*].spec.serviceMonitorSelector}"
In some case, you might need to add something like:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
...
release: prometheus-community