Prometheus Target Down — Scrape Failure Fix
In this tutorial, you'll learn about Prometheus Target Down. We cover key concepts, practical examples, and best practices.
Your Prometheus dashboard shows Target Down in red — the exporter or application endpoint isn't reachable. Prometheus couldn't scrape metrics from the configured target.
The Problem
# WRONG — target specified with wrong port or path
scrape_configs:
- job_name: 'node'
static_configs:
- targets: ['localhost:9101']
Prometheus UI shows http://localhost:9101/metrics — DOWN. Port 9101 is wrong — the node exporter runs on port 9100 by default. The target endpoint returns connection refused.
Step-by-Step Fix
1. Verify the target endpoint is accessible
# From the Prometheus server
curl -v http://target-host:9100/metrics
# Check if the port is open
nc -zv target-host 9100
2. Fix the scrape configuration
scrape_configs:
- job_name: 'node'
scrape_interval: 15s
scrape_timeout: 10s
static_configs:
- targets:
- 'localhost:9100'
- 'worker-1:9100'
- 'worker-2:9100'
relabel_configs:
- source_labels: [__address__]
target_label: instance
3. Check firewall and network rules
# Allow Prometheus to reach the target
sudo ufw allow from prometheus-server to any port 9100
4. Check if the exporter is running
# On the target machine
systemctl status node_exporter
journalctl -u node_exporter -n 20
5. Use service discovery (Consul, Kubernetes, EC2)
scrape_configs:
- job_name: 'kubernetes-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
action: keep
regex: true
Expected output in Prometheus UI:
Target: http://localhost:9100/metrics
State: UP
Last Scrape: 2s ago
Scrape Duration: 0.012s
Error: (none)
Prevention Tips
- Verify exporter ports with
curl http://host:port/metricsbefore adding to config - Use service discovery (Kubernetes, Consul) instead of static targets
- Add
scrape_timeoutlower thanscrape_interval - Set up Prometheus Alertmanager rules for target down
- Use blackbox exporter for endpoint health monitoring
Common Mistakes with target down
- Forgetting
deriving (Show, Eq)on custom data types needed for debugging - Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists
These mistakes appear frequently in real-world PROMETHEUS code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.
Practice Exercise
Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.
This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro