<p>I have a Redis cluster and Redis-exporter in two separate deployments in the same namespace of a Kubernetes cluster. I am using Prometheus operator to monitor the cluster, but I can not find a way to set up the exporter and the operator. I have set up a service targeting the Redis exporter(check below) and a ServiceMonitor(also below). If I port forward to the Redis exporter service I can see the metrics. Also, the Redis exporter logs do not show issues.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: foo
  name: redis-exporter
  labels:
    app: redis-exporter
spec:
  replicas: 1
  selector:
    matchLabels:
      app: redis-exporter
  template:
    metadata:
      annotations:
        prometheus.io/scrape: &quot;true&quot;
        prometheus.io/port: &quot;9121&quot;
      labels:
        app: redis-exporter
    spec:
      containers:
      - name: redis-exporter
        image: oliver006/redis_exporter:latest
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
        env:
        - name: REDIS_ADDR
          value:  redis-cluster.foo.svc:6379
        ports:
        - containerPort: 9121
</code></pre>
<p>My service and servicemonitor</p>
<pre><code>kind: Service
metadata:
  name: redis-external-exporter
  namespace: foo
  labels:
    app: redis
    k8s-app: redis-ext
  annotations:
    prometheus.io/scrape: 'true'
    prometheus.io/port: &quot;9121&quot;
spec:
  ports:
  - name: redis-ext
    port: 9121
    protocol: TCP
    targetPort: 9121
  selector:
    app: redis-exporter
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: redis-external-exporter
  namespace: bi-infra
  labels:
    app: redis-external-exporter
    k8s-app: redis-monitor
spec:
  jobLabel: app
  selector:
    matchLabels:
      app: redis-ext
  namespaceSelector:
    matchNames:
    - foo
  endpoints:
  - port: redis-ext
    interval: 30s
    honorLabels: true
</code></pre>
<p>If I switch to a sidecar Redis exporter next to the Redis cluster all is working properly. Has anyone faced such issue?</p>

<p>I was missing spec.endpoints.path on the ServiceMonitor</p>
<p>Here is an example manifest from adding new scraping targets and troubleshooting <a href="https://blog.pilosus.org/posts/2019/06/01/prometheus-operator-no-active-targets/" rel="nofollow noreferrer">tutorial</a>.</p>
<pre><code>apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: monitoring-pili
  namespace: monitoring
  labels:
    app: pili-service-monitor
spec:
  selector:
    matchLabels:
      # Target app service
      app: pili
  endpoints:
  - interval: 15s
    path: /metrics    &lt;---
    port: uwsgi
  namespaceSelector:
    matchNames:
    - default
</code></pre>
