<p>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. </p>

<p>I have a simple micro service with prometheus enabled, <a href="https://github.com/sloppycoder/profile-svc" rel="nofollow noreferrer">see github for source</a></p>

<p>I can run it locally, or deployed into openshift. In both cases I can see the metrics output from http://:/actuator/prometheus endpoint.</p>

<p>Since <a href="https://github.com/openshift/installer" rel="nofollow noreferrer">Openshift 4.0 Developer Preview</a> comes with prometheus and <a href="https://github.com/coreos/prometheus-operator" rel="nofollow noreferrer">prometheus operator</a>, 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.</p>

<p>here is my servicemonitor.yaml</p>

<pre><code>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
</code></pre>

<p>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</p>

<p>openshift-monitoring/profile-svc-monitor/0 (0/0 up)</p>

<p>Can anyone shed some light on this?</p>

<p>Your <code>namespaceSelector</code> should be at the same level as <code>selector</code>.</p>
