13.12 Troubleshooting table
Why: the problem
It is Monday morning at a TCS client project. The manager says "the Grafana dashboard has been empty since Saturday". Nobody knows where to start. Is it Grafana? Prometheus? The exporter? The network? A good troubleshooter does not guess. She follows the number from where it is born to where it is shown, one hop at a time: exporter, network, Prometheus target, PromQL, Grafana data source, panel. At the first hop that fails, she has found the problem. It is like a water pipe from the tank to the tap: if the tap is dry, you check each joint from the tank down. This lesson gives you that path, the exact command for each hop, and the most common red errors with fixes.
What we will build
You will learn the hop-by-hop check for "no data", run it as one script, and then fix three real broken setups on purpose: a target that is DOWN, a Grafana panel with no data, and an alert that never fires. You will also learn the Prometheus self-metrics that tell you when Prometheus itself is unhealthy.
What: every term in plain English
- Hop — One step in the path of a number: exporter, network, Prometheus, query, Grafana.
- Target DOWN — Prometheus could not scrape the target in the last attempt.
- Scrape error — The reason for DOWN: timeout, connection refused, 404, wrong format.
- Self-monitoring — Prometheus has its own metrics, like prometheus_tsdb_head_series and scrape durations.
- Query inspector — A Grafana tool that shows the exact query and response of a panel.
- Stale — A series that stopped coming. Prometheus marks it stale after a few minutes.
- Clock skew — Server clocks out of sync. Graphs look wrong and alerts misbehave.
- promtool / amtool — Command line checkers for Prometheus and Alertmanager.
How: step by step
-
Hop 1: exporter
curl -s -m 3 TARGET_IP:9100/metrics | head -3What it does: Is the exporter alive?
Output
# HELP go_gc_duration_seconds ... -
Hop 2: network from Prometheus
sudo docker compose exec prometheus wget -qO- -T 3 TARGET_IP:9100/metrics | head -1What it does: Can Prometheus reach it?
Output
# HELP go_gc_duration_seconds ... -
Hop 3: target state
curl -s localhost:9090/api/v1/targets | python3 -m json.tool | grep -E "scrapeUrl|health|lastError"What it does: Prometheus view and last error.
Output
"health": "up", "lastError": "" -
Hop 4: the query
curl -s "localhost:9090/api/v1/query?query=up" | grep -o '"result":\[[^]]*'What it does: Does Prometheus have data?
Output
"result":[{"metric":{"__name__":"up",...},"value":[...,"1"] -
Hop 5: Grafana data source
curl -s -u admin:YOUR_PASS localhost:3000/api/datasources/name/Prometheus | grep -o '"url":"[^"]*"'What it does: Is Grafana pointing to the right place?
Output
"url":"http://prometheus:9090" -
Hop 6: the panel
Panel menu, Inspect, QueryWhat it does: See the real request and response.
Output
Request ... Response: 200, 1 series
Example 1: A hop-by-hop "no data" checker script
Stack. Bash, Prometheus API, Docker Compose
Goal. A hop-by-hop "no data" checker script.
nodata.sh
#!/usr/bin/env bash
# usage: bash nodata.sh 10.0.1.25:9100
T=$1
ok() { echo "OK $1"; }
bad() { echo "FAIL $1"; exit 1; }
curl -s -m 3 "http://$T/metrics" | grep -q "^node_" && ok "exporter answers" || bad "exporter not answering on $T"
sudo docker compose exec -T prometheus wget -qO- -T 3 "http://$T/metrics" | grep -q "^node_" \
&& ok "Prometheus container can reach $T" || bad "network blocked from Prometheus to $T"
H=$(curl -s localhost:9090/api/v1/targets | python3 -c "
import sys, json
for t in json.load(sys.stdin)['data']['activeTargets']:
if t['labels'].get('instance') == '$T': print(t['health'], t['lastError'])")
[ -n "$H" ] || bad "$T is not in prometheus.yml"
case "$H" in up*) ok "target is up";; *) bad "target state: $H";; esac
curl -s "localhost:9090/api/v1/query?query=up{instance=\"$T\"}" | grep -q '"1"\]' && ok "query up returns 1" || bad "no data in Prometheus"
echo "All hops fine. Check the Grafana data source URL and the panel query."
What each line does
ok() / bad()— Small helpers. bad stops at the first broken hop.curl -s -m 3— Try for 3 seconds, quietly.docker compose exec -T prometheus wget— Tests from inside the Prometheus container, the same place Prometheus scrapes from.python3 -c "..."— Reads the targets JSON and prints health and lastError for our target.case "$H" in up*)— Checks if the health starts with up.up{instance="..."}— The up metric for this target must be 1.
Green output
$ bash nodata.sh 10.0.1.25:9100
OK exporter answers
FAIL network blocked from Prometheus to 10.0.1.25:9100
Expected result. The script found the broken hop in 5 seconds: the server is fine but Prometheus cannot reach it. Next step: the security group.
Example 2: Fix a DOWN target, then a Grafana panel with no data
Stack. AWS security groups, Prometheus label API, Grafana
Goal. Fix a DOWN target, then a Grafana panel with no data.
Broken 1: target DOWN
Targets page:
node http://10.0.1.25:9100/metrics DOWN
Error: Get "http://10.0.1.25:9100/metrics": context deadline exceeded
Fix 1
# allow 9100 from the Prometheus security group (AWS CLI)
aws ec2 authorize-security-group-ingress \
--group-id sg-0web1234567890abc \
--protocol tcp --port 9100 \
--source-group sg-0mon1234567890abc
Broken 2: panel says No data
Panel query: node_filesystem_avail_bytes{mountpoint="/data", instance=~"$server"}
Query inspector: Response 200, result: []
Fix 2
# what mount points really exist?
curl -s "localhost:9090/api/v1/label/mountpoint/values"
What each line does
context deadline exceeded— Prometheus waited and got no answer. Almost always a firewall or security group.authorize-security-group-ingress— Opens port 9100 on the web servers only for members of the monitoring security group.--source-group— Safer than an IP; works even when IPs change.result: []— Prometheus answered but nothing matched the labels./api/v1/label/mountpoint/values— Lists real values of a label. Here /data does not exist on that server.
Green output
Fix 1 result:
node http://10.0.1.25:9100/metrics UP last scrape 4s ago
Fix 2 result:
{"status":"success","data":["/","/boot/efi","/var/lib/mysql"]}
Panel query changed to mountpoint="/var/lib/mysql" - panel shows 63%
Expected result. Two common failures fixed: the network for the DOWN target, and a wrong label value for the empty panel.
Example 3: An alert that never fires, and Prometheus checking itself
Stack. Prometheus API, PromQL self-metrics
Goal. An alert that never fires, and Prometheus checking itself.
Debug the alert
# 1. Is the rule loaded and what is its state?
curl -s localhost:9090/api/v1/rules | python3 -m json.tool | grep -A3 '"name": "DiskAlmostFull"'
# 2. Run the alert expression without the threshold
curl -s --data-urlencode 'query=100 * (1 - node_filesystem_avail_bytes{mountpoint="/"} / node_filesystem_size_bytes{mountpoint="/"})' \
localhost:9090/api/v1/query | grep -o '"value":[^]]*'
Prometheus self-health queries
# scrapes failing in the last 5 minutes, per job
sum by (job) (up == 0)
# slowest targets to scrape
topk(5, scrape_duration_seconds)
# rule groups that take too long
prometheus_rule_group_last_duration_seconds > 10
# notifications that failed to reach Alertmanager
rate(prometheus_notifications_errors_total[5m]) > 0
# memory series right now
prometheus_tsdb_head_series
What each line does
grep -A3— Shows the rule line and 3 lines after it: state, health, lastError.--data-urlencode— Lets curl send a query with spaces and braces safely.Run without the threshold— See the real value. If it is 82 and the rule says above 85, it will not fire.scrape_duration_seconds— How long each scrape took. Near the timeout means trouble soon.prometheus_notifications_errors_total— Prometheus could not send alerts to Alertmanager.
Green output
"name": "DiskAlmostFull",
"state": "inactive",
"health": "ok",
"value":[1761411000,"82.4"
Self-health:
topk scrape_duration_seconds: {job="node", instance="10.0.2.40:9100"} 4.8 (timeout is 10s)
prometheus_tsdb_head_series 38120
Expected result. The alert is fine, the value is just 82.4, below 85. And Prometheus shows one slow target to look at. Always check the real value before blaming the rule.
Verify: did it work?
-
Run the checker on every target
for t in 10.0.1.12:9100 10.0.1.25:9100; do bash nodata.sh $t; doneWhat it does: Each target ends with "All hops fine".
Output
OK exporter answers OK Prometheus container can reach ... OK target is up OK query up returns 1 -
Check server clocks
timedatectl | grep synchronizedWhat it does: Clocks must be in sync.
Output
System clock synchronized: yes
When it is red 1
server returned HTTP status 404 Not Found
Cause. The metrics path is wrong. Spring Boot uses /actuator/prometheus, not /metrics.
Fix, step by step
- Add metrics_path: /actuator/prometheus to that job.
- Reload Prometheus.
- Check the target is UP.
When it is red 2
Error scraping target: out of order sample / time too far into the future
Cause. The server clock is wrong.
Fix, step by step
- sudo timedatectl set-ntp true
- On AWS use the Amazon Time Sync service (169.254.169.123).
- Wait one minute and check the target.
When it is red 3
Grafana: bad gateway (502)
Cause. Grafana cannot reach Prometheus, often after Prometheus restarted with a new IP or crashed.
Fix, step by step
- sudo docker compose ps prometheus
- sudo docker compose logs --tail 30 prometheus
- Use the service name in the data source URL, not an IP.
Cleanup
-
Remove the checker
rm nodata.shWhat it does: Lab file only.
Output
(no output) -
Revert the lab security group rule
aws ec2 revoke-security-group-ingress --group-id sg-0web1234567890abc --protocol tcp --port 9100 --source-group sg-0mon1234567890abcWhat it does: Only if this was a lab.
Output
{ "Return": true }
Ravindra Bagale's Tip
If the pipe is dry, check each joint from the tank: exporter, network, target, query, Grafana. Do not guess.
नाळ कोरडी असेल तर टाकीपासून एक एक joint तपासा. Exporter, network, target, query, Grafana. अंदाज लावू नका.
पाइप सूखी हो तो टंकी से एक-एक जोड़ जाँचो. Exporter, network, target, query, Grafana. अंदाज़ा मत लगाओ.
Practice tasks
Easy Make a hop card
Why: A printed card speeds up on-call.
What to do: Write the 6 hops and one command for each on one card.
- Copy from How: step by step.
Check: Card fits on one page.
Medium Alert on Prometheus itself
Why: Who watches the watcher?
What to do: Add an alert when prometheus_notifications_errors_total grows.
- rate(...[5m]) > 0 for 10m.
Check: The alert fires when Alertmanager is stopped.
Hard Dead man switch
Why: If Prometheus dies, no alert fires at all.
What to do: Add an always-firing Watchdog alert and route it to a heartbeat service.
- expr: vector(1)
- Route to Healthchecks.io or PagerDuty heartbeat.
Check: You get paged when the heartbeat stops.
Easy Say monitoring troubleshooting in two lines
Why: If you can say it simply, you understand it. Juniors and interviewers both want the short version first.
What to do: Write two short lines about monitoring troubleshooting for a fresher who knows only Linux, Git and Docker basics.
- Write the problem it solves.
- Write the one command, query or config line you use for it.
- Read it aloud to a friend.
Check: A fresher understands it without asking a question.
Easy Keep a throwaway monitoring lab
Why: Practice needs a lab you can break. If it gets messy, you delete the containers and start again in one minute.
What to do: Run Node Exporter in Docker and read its metrics page.
- docker run -d --name ne -p 9100:9100 prom/node-exporter
- curl -s localhost:9100/metrics | grep node_load1
- docker rm -f ne
Check: You see a line that starts with node_load1 and a number.
Medium Do it on a second stack
Why: Monitoring ideas must work on Prometheus and on CloudWatch. Only the tool changes, not the thinking.
What to do: Repeat this lesson on a different stack than the one you used first.
- If you used Prometheus, try the CloudWatch console or AWS CLI.
- Keep the same question: is it up, is it fast, is it failing, is it full?
- Compare the two graphs side by side.
Check: Both tools answer the same question with a number and a graph.
Medium Break it on purpose
Why: You must know the red error by face. During an outage there is no time to read slowly.
What to do: Cause one error from the "When it is red" part of this lesson and fix it.
- Follow the error section.
- Copy the exact message into your notes.
- Write the fix in one line.
Check: You fixed it using only the steps, without searching the web.
Medium Write a one-page runbook
Why: At 2 a.m. nobody remembers PromQL. A short page saves the on-call person.
What to do: Write a one-page runbook for this lesson.
- Title, when the alert fires, the graph to open, the exact commands, how to check, how to undo.
Check: A teammate can follow it alone, without calling you.
Hard Explain it like an interview
Why: Interviewers want real stories, not definitions.
What to do: Record a 60 second answer about this lesson.
- Say the problem, the metric you watched, the number you saw and the fix.
Check: Your answer has a real metric name and a real number.
Hard Draw the flow top to bottom
Why: A drawing shows where a number is born and where it ends up.
What to do: Draw this lesson as boxes from top to bottom.
- Start at the server or app, go through the exporter, Prometheus or CloudWatch, then Grafana, then the alert on your phone.
Check: Each box matches a real command or file in this lesson.
Homework: try at home
Try at home
At home, break your lab in three ways (stop the exporter, change the Grafana URL to localhost, set a wrong mountpoint) and fix each one using only the hop-by-hop steps. Time yourself; aim for under 3 minutes each.
Recap
- Follow the number hop by hop: exporter, network, target, query, data source, panel.
- The first failing hop is the problem.
- context deadline exceeded is usually the network.
- No data in a panel is often a wrong label value.
- Watch Prometheus self-metrics and add a Watchdog alert.
FAQ
Why is my target UP but the panel empty?
The panel query has wrong labels or the time range is wrong. Use Query inspector.
Why do graphs have gaps?
Scrapes failed or took too long at those times. Check scrape_duration_seconds.
How do I know Alertmanager got the alert?
Open port 9093 UI or run amtool alert query.
Should I restart Prometheus to fix things?
Rarely. Find the hop first. Restarting hides the evidence.
What is the Watchdog alert?
An alert that is always firing, so silence means the alert pipeline is broken.
Interview questions
-
A Grafana dashboard shows no data. How do you debug?
Check exporter, network from Prometheus, target health and lastError, run the query in Prometheus, check the Grafana data source URL and the panel with Query inspector.
-
What does up == 0 mean?
The last scrape of that target failed.
-
How do you monitor Prometheus itself?
Self-metrics like head series, rule duration, notification errors, scrape duration, a second Prometheus or Watchdog alert.
-
An alert never fires. What do you check?
Rule loaded and healthy, the expression value without threshold, labels match, for: time, and Prometheus to Alertmanager connection.
-
How do clock issues affect monitoring?
Samples get rejected or appear at wrong times; keep NTP synced.
Quick quiz
Q1. What is the first hop to check?
The exporter /metrics page.
Q2. What does context deadline exceeded usually mean?
A firewall or security group blocks the scrape.
Q3. Which API lists real label values?
/api/v1/label/NAME/values.
Q4. Why test from inside the Prometheus container?
That is where scrapes start; your laptop may have a different network path.
Q5. What is a common cause of "time too far into the future"?
Clock skew.
Did you understand? Let us try it once more.
Revision card
Interview card