<p>I'm using Kube-prometheus with Prometheus-Operator to monitor my K8s cluster. I've deployed Jenkins on my cluster and want to start to get metrics here using ServiceMonitor.</p>

<p>I've installed the Prometheus plugin which exposes the metrics using <code>/prometheus</code> or by <code>/metrics/API_KEY/metrics</code>, this works fine if I create a new static job. However, if I want to use ServiceMonitor, it does not work.</p>

<pre><code>apiVersion: monitoring.coreos.com/v1                                                                                                                                                                        
kind: ServiceMonitor
metadata:
  labels:
    k8s-app: jenkins
  name: jenkins
  namespace: monitoring
spec:
  endpoints:
  - interval: 30s 
    port: http
    path: /metrics/y1H6G16T-DhqpHdW9XwHWnP9FWAXMMfy4XnXVnyoIOEV3-gPJZKN284OFUcVkPxL/metrics
  selector:
    matchLabels:
      jenkins: main
</code></pre>

<p>I don't know about ServiceMonitor, but I monitor my Jenkins instance without any problem, using annotations on Jenkins' service :</p>

<pre><code>prometheus.io/scrape: "true"
prometheus.io/port: "8080"
prometheus.io/path: "/prometheus"
</code></pre>
