<p>I am trying to configure a prometheus to monitor a simple flask app, but its very weird that the prometheus does show the service in the drop down, but it shows nothing when I click in the dropdown:</p>
<p><a href="https://i.stack.imgur.com/KeuEB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KeuEB.png" alt="blank" /></a></p>
<p>Here is the code:</p>
<p>app.py</p>
<pre><code>from flask import Flask
from prometheus_flask_exporter import PrometheusMetrics

app = Flask(__name__)
metrics = PrometheusMetrics(app)

@app.route('/')
def hello():
    return &quot;Hello World!&quot;

if __name__ == &quot;__main__&quot;:
    app.run(host=&quot;0.0.0.0&quot;, port=5000)

</code></pre>
<p>flask-deployment.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: flask-app
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flask-app
  template:
    metadata:
      labels:
        app: flask-app
    spec:
      containers:
      - name: flask-app
        image: starian/flask-app1
        ports:
        - containerPort: 5000
          name: webapp        
</code></pre>
<p>flask-service.yaml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: flask-app-service
spec:
  selector:
    app: flask-app
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: webapp
  type: LoadBalancer

</code></pre>
<p>service-monitor.yaml</p>
<pre><code>apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: flask-app
  labels:
    release: prometheus-stack
spec:
  selector:
    matchLabels:
      app: flask-app
  endpoints:
  - port: http
    interval: 5s
    path: /metrics

</code></pre>
<p>Dockerfile</p>
<pre><code>FROM python:3.8-slim

WORKDIR /app
COPY . /app

RUN pip install flask
RUN pip install prometheus_flask_exporter

CMD [&quot;python&quot;, &quot;app.py&quot;]
</code></pre>
<p>I check everything that I know of:
THe metrics does show in the the flask app. I can curl it.
All the services is on.</p>
<p>What could goes wrong?</p>

user2459179
<p><code>servicemonitor</code> object looks for services with the label selectors that you give in the manifest , the name of the object is telling you exactly what it does. it looks for a <code>service</code> with the <code>app: flask-app</code> label not the <strong>pod</strong>.
so if you look at your service manifest it does not have <strong>lables</strong> so the service monitor is monitoring nothing , if you create another service monitor with another labelselector it is shown just like that in prometheus targets.<br />
to sum it up , edit your service manifest:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: flask-app-service
  labels:
    app: flask-app
spec:
  selector:
    app: flask-app
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: webapp
  type: LoadBalancer
</code></pre>
<p>Hope that helps! :)</p>
