Ping & Latency Dashboard — Step‑by‑Step

Probe HTTP/TCP endpoints, collect metrics in Prometheus, alert with Alertmanager, and visualize in Grafana — all in one day.

Jump to:

1) Prerequisites

Windows users: run Docker with WSL2. If you see Hyper‑V/WSL prompts, enable WSL in “Turn Windows features on or off” and reboot.

2) Get the code

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).

3) Run the stack

From the project root (same folder as docker-compose.yml):

docker compose up -d --build

Open the UIs

Check containers

docker compose ps

4) Configure endpoints

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
Tip: This app measures HTTP/TCP latency (no raw ICMP ping), which works without extra privileges and matches SRE‑style checks.

5) Verify metrics & dashboards

Quick via metrics endpoint

curl -s http://localhost:8000/metrics | grep -E '^ping_(latency_seconds|up){'

Look for labels like target="https://www.google.com" and name="google".

Prometheus queries

Grafana dashboard

Open Grafana → folder Ping → dashboard Ping & Latency.

6) Trigger & see alerts

Prometheus alerts are defined in prometheus/alerts.yml:

Fastest way to test

  1. Set one target threshold_seconds: 0.001 and save.
  2. Wait 15–30s (or restart pinger).
  3. Open Alertmanager: / → you should see HighLatency.
  4. Tail webhook payloads from pinger:
docker logs -f pinger

7) Real notifications (Slack)

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
In this starter, a local webhook receiver posts to http://pinger:8000/alert so you can see alert payloads end‑to‑end. Swap the route.receiver to slack to notify Slack.

8) Monitor your own local services

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
Linux note: Add this under pinger: in docker-compose.yml to map host.docker.internal:
extra_hosts:
  - "host.docker.internal:host-gateway"

9) Troubleshooting

No data in Prometheus

Alerts never fire

Port already in use

Change the left side of the port in docker-compose.yml (e.g., 3001:3000) and restart.

10) Stop / start / reset

Pause (keep containers)

docker compose stop
# later
docker compose start

Shutdown (remove containers)

docker compose down
# start again
docker compose up -d

Clean slate (also volumes/images)

docker compose down --volumes --rmi local --remove-orphans

How it works

Pinger
probes endpoints; exposes /metrics
Prometheus
scrapes & stores; evaluates alerts
Alertmanager
routes notifications
Slack/Email/Webhook
Grafana
dashboards via Prometheus