I'm trying to create a servicemonitor that will instruct prometheus to scrape the metrics from my spring-boot service, but can't find the right way to do that.
I have a simple micro service with prometheus enabled, see github for source
I can run it locally, or deployed into openshift. In both cases I can see the metrics output from http://:/actuator/prometheus endpoint.
Since Openshift 4.0 Developer Preview comes with prometheus and prometheus operator, I want to simply create a servicemontior object which will trigger the operator to create prometheus configuration that will scrape by pod metrics endpoint, but I can't seem to get it to work, despite trying various tutorials.
here is my servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: profile-svc-monitor
namespace: openshift-monitoring
labels:
app: profile-svc
spec:
selector:
matchLabels:
deploymentconfig: profile-svc
namespaceSelector:
matchNames:
- my-project
endpoints:
- port: http
scheme: http
path: '/actuator/prometheus'
interval: 15s
honorLabels: false
After creating the object the prometheus console shows the rules for scraping has been created, but i can't see any pods. Under menu "Status" -> "Targets", it shows
openshift-monitoring/profile-svc-monitor/0 (0/0 up)
Can anyone shed some light on this?
Your namespaceSelector
should be at the same level as selector
.