<p>It seems that I can't get my target scraped by <code>prometheus</code> neither via the annotation method nor the <code>ServiceMonitor</code> workaround.</p>
<p>Here is the <code>spec</code> scetion of my <code>Service</code> Object exposing the metrics</p>
<pre><code>spec:
  clusterIP: 10.107.228.89
  ports:
  - name: metricsport
    port: 8282
    protocol: TCP
    targetPort: 8282
  selector:
    app: my-app
    release: my-app
  sessionAffinity: None
  type: ClusterIP
</code></pre>
<p>This <strong>DOES</strong> expose metrics, which I verify by <code>curl</code>ing it via another pod from within the cluster</p>
<pre><code>curl http://my-service-metrics:8282/metrics
(...a lot of metrics)
</code></pre>
<p>Here is my <code>ServiceMonitor</code> <code>spec</code></p>
<pre><code>spec:
  endpoints:
  - path: /metrics
    port: metricsport
  namespaceSelector:
    matchNames:
    - default
  selector:
    matchLabels:
      app: my-app
      release: my-app
</code></pre>
<p>What else should I do/try to get my metrics being scraped by <code>prometheus</code>?</p>
<p>(the target does not appear in my <code>http://prometheus/targets</code>)</p>

pkaramol
<p>Answered in Slack, need to make sure the labels on the ServiceMonitor object itself match the <code>serviceMonitorSelector</code> on the Prometheus object.</p>
