How to Monitor Network Devices using Ping with Prometheus and Grafana

March 18, 2025

Network Monitoring

Network Monitoring using Ping with Prometheus and Grafana

Whilst network monitoring is an essential to work network environments and cloud services, it is often overlooked within the home. However, with increasing numbers of devices in the home and the expectation of them being always available, some network monitoring can save you from some nasty surprises when you are in a hurry.

Devices such as printers and access points can have a nasty habit of being offline when you need them, so a simple solution is to apply some network monitoring using ICMP - ping testing.

The Prometheus Ping Exporter is an easy way to achieve this. More information on it can be found here.

Environment Setup

The easiest way to configure Grafana, Prometheus and the Ping Exporter is to use Docker containers. The instructions for the initial part of the setup can be found here, and you will need to have this (or and existing Prometheus and Grafana environment) configured before setting up the Ping Exporter.

With the Prometheus and Grafana set up out of the way, you should be able to add the Ping Exporter to the setup.

Ping Exporter Setup

On your docker host, create a directory for the ping exporter, eg:

mkdir ping_exporter

You should now create a config file for the exporter, and edit the contents of this:

cd ping_exporter
nano config.yml

The config file needs to contain the hosts or addresses that you want to monitor, eg:

targets:
  - myhost1.local
  - myhost2.local
  - www.google.com

dns:
  refresh: 2m15s
  nameserver: 192.168.2.1

ping:
  interval: 5s
  timeout: 10s
  history-size: 42
  size: 120

options:
  disableIPv6: false

Run the ping_exporter docker container, mapping the config.yml you have edited.

sudo docker run --init -d -p 9427:9427 -v /home/user/ping_exporter/config.yml:/config/config.yml --name ping_exporter czerwonk/ping_exporter

Check the container is running:

sudo docker ps

curl localhost:9427

Alternatively, open the dockerhost IP or hostname and port in a browser, eg “http://192.168.2.10:9427”

Updating Prometheus

With the exporter confirmed as running, you should now update the Prometheus configuration file to add the Ping Exporter - using the docker hostname/IP and ping exporter port as a target.

scrape_configs: # add scrape_configs line if it does not exist, otherwise add an additional job
  - job_name: 'ping_exporter'
    static_configs:
      - targets: ['192.168.2.10:9427'] # address of ping exporter
    metrics_path: /metrics

You now need to restart the prometheus container to refresh the configuration - if you have followed the example setup, this can be done by running the following:

sudo docker restart prometheus

If not, you will have to identify the prometheus container using the following to find all running containers:

sudo docker ps

A minute or two after the restart, the ping metrics should be visible and you can now add these to your Grafana dashboards as desired.

Demonstration Video

A demonstration video of the setup can be found here: