Probe HTTP/TCP endpoints, collect metrics in Prometheus, alert with Alertmanager, and visualize in Grafana — all in one day.
docker --version
, docker compose version
)git --version
)Download or clone the repository that contains this guide and the docker-compose.yml
.
git clone https://github.com/shri-124/ping-latency-dashboard.git
cd ping-latency-dashboard
If you don’t use git, just create the folder structure and copy the files from the project (see README).
From the project root (same folder as docker-compose.yml
):
docker compose up -d --build
docker compose ps
Edit config/targets.yml
. Supports HTTP/HTTPS (full request latency) and TCP (connect latency):
interval_seconds: 15
request_timeout_seconds: 5
targets:
- name: google
url: https://www.google.com
threshold_seconds: 0.35
- name: cloudflare-dns-tcp
url: tcp://1.1.1.1:53
threshold_seconds: 0.05
- name: github
url: https://github.com
threshold_seconds: 0.40
The pinger auto‑reloads this file every cycle. To apply immediately:
docker compose restart pinger
curl -s http://localhost:8000/metrics | grep -E '^ping_(latency_seconds|up){'
Look for labels like target="https://www.google.com"
and name="google"
.
label_values(ping_latency_seconds, target)
sum by (name, target) (ping_up)
ping_latency_seconds
Open Grafana → folder Ping → dashboard Ping & Latency.
Prometheus alerts are defined in prometheus/alerts.yml
:
ping_latency_seconds > ping_latency_threshold_seconds
for 1mping_up == 0
for 2mthreshold_seconds: 0.001
and save.docker logs -f pinger
Edit alertmanager/alertmanager.yml
to add Slack (or email). Example Slack config:
route:
receiver: slack
group_by: ["alertname","name","target"]
group_wait: 10s
group_interval: 1m
repeat_interval: 2h
receivers:
- name: slack
slack_configs:
- api_url: https://hooks.slack.com/services/YOUR/WEBHOOK/URL
channel: "#alerts"
send_resolved: true
Apply the change:
docker compose restart alertmanager
http://pinger:8000/alert
so you can see alert payloads end‑to‑end. Swap the route.receiver
to slack
to notify Slack.Add your app or DB as a target in config/targets.yml
:
targets:
- name: my-api
url: http://host.docker.internal:8080
threshold_seconds: 0.25
- name: postgres
url: tcp://host.docker.internal:5432
threshold_seconds: 0.05
pinger:
in docker-compose.yml
to map host.docker.internal
:
extra_hosts:
- "host.docker.internal:host-gateway"
pinger:8000
must be UPdocker logs pinger
Change the left side of the port in docker-compose.yml
(e.g., 3001:3000
) and restart.
docker compose stop
# later
docker compose start
docker compose down
# start again
docker compose up -d
docker compose down --volumes --rmi local --remove-orphans