How to Fix a Prometheus Scrape Config

If a Prometheus query returns nothing, Prometheus probably isn't scraping your target - a wrong port, path, or a down endpoint. Here's the scrape_configs structure and how to confirm it on the Targets page.

DevOps Engineerprometheusobservabilitymetrics

How scraping works

Prometheus pulls metrics: on an interval it HTTP-GETs each target's metrics endpoint (default /metrics) and stores what it finds. If a graph is empty, either Prometheus isn't scraping the target, or the target isn't exposing that metric.

The scrape config

global:
  scrape_interval: 15s

scrape_configs:
  - job_name: 'flask-app'
    static_configs:
      - targets: ['localhost:8000']    # host:port where /metrics lives
    # metrics_path: /metrics           # default; override if different

The two fields that cause "empty graph": - targets must be the exact host:port your app serves metrics on. Scraping localhost:8001 when the app is on 8000 silently collects nothing. - metrics_path defaults to /metrics; set it if your app uses a different path.

Step 1: check the Targets page

Prometheus UI -> Status -> Targets. Each target shows UP or DOWN with the error:

Step 2: confirm the metric exists

curl localhost:8000/metrics | grep app_requests_total

If it's not there, the app isn't emitting it - e.g. a counter was never defined or incremented:

from prometheus_client import Counter
REQUESTS = Counter("app_requests_total", "Total requests")
# ... and actually call REQUESTS.inc() on each request

Step 3: reload Prometheus

After fixing the config, reload (no restart needed if --web.enable-lifecycle is on):

curl -X POST http://localhost:9090/-/reload

Then re-check Targets - the job should be UP and the metric should graph.

Want to try it hands-on? HeyDevJob gives you this exact setup in a live cloud workspace in your browser - edit it, run it, and see it work. Free, nothing to install.

Try it in a workspace →

What you'll practice

FAQ

Why is my Prometheus graph empty?

Prometheus isn't scraping the target, or the target isn't exposing that metric. Check Status -> Targets: DOWN means a wrong port/path or the app is down; UP with a missing metric means the app never defined/incremented it.

How do I tell Prometheus what to scrape?

Add a job under scrape_configs with static_configs.targets: ['host:port'] pointing at where /metrics is served, and set metrics_path if it isn't the default /metrics.

How do I check if a Prometheus target is healthy?

Open the Prometheus UI -> Status -> Targets. It lists every target as UP or DOWN with the exact error (connection refused, 404, etc.).

Keep learning

Fix the Nginx 502 Bad GatewayDevOps projectRecover a Crashed Linux ServiceDevOps projectCorrect a Postgres Port MismatchDevOps projectDevOps roadmapStep by step to hiredDevOps interview questionsSTAR answersAll DevOps projectsProjects hub

Learn it by doing. Open this in a live cloud workspace, make the change yourself, and keep a record of the work you can share.

Open the workspace →