This repository provides a comprehensive monitoring solution for Host machines and Docker containers using Telegraf, Prometheus, and Grafana. Grafana offers intuitive dashboards to visualize system metrics collected by Prometheus and Telegraf. The setup includes pre-configured files to quickly deploy and visualize metrics for both Host systems and Docker containers. This combination of tools results in a powerful and efficient monitoring solution that provides complete visibility into your system's health.
Before you begin, ensure you have the following installed:
- Docker: Install Docker
- Docker Compose: Install Docker Compose
Telegraf is used as a metrics data collector, while Prometheus collects metrics from the data collector and stores them in its database. Grafana is configured to query metrics using(PrompQL), with the results rendered on the dashboard.
To deploy monitoring containers:
echo DOCKER_GROUP_ID=$(stat -c '%g' /var/run/docker.sock) > .env
export TELEGRAF_HOST=http://telegraf:9273
envsubst < prometheus.template.yml > prometheus.yml
docker compose --profile monitor up -dAlternatively, you can deploy the data collector (i.e., Telegraf) on the target machine that needs to be monitored, and deploy Prometheus and Grafana on a different machine for metric data storage and dashboard visualization.
- To deploy Telegraf(on a target machine)
echo DOCKER_GROUP_ID=$(stat -c '%g' /var/run/docker.sock) > .env
docker compose --profile telegraf up -d- To deploy Prometheus and Grafana(on a different machine)
Since, Telegraf is deployed to a different machine, you need to setTELEGRAF_HOST
export TELEGRAF_HOST=<ip of the target machine>:9273
envsubst < prometheus.template.yml > prometheus.yml
docker compose --profile grafana-prometheus up -dCheck if containers are running and not exited.
docker compose psGrafana dashboard can be accessed by navigating to http://<IP or localhost>:3000. The default username and password are admin.
Installing dashboard: -
- Navigate to
connection > Data Sourcesfrom the panel. - Add Prometheus as a data source.
- Specify
http://prometheus:9090in the URL. - Test the connection.
- Navigate to the Dashboard from the panel.
- Click on 'Create New Dashboard' and then 'Import Dashboard'.
- Visit grafana.com Dashboard.
- Click on the
Copy ID to Clipboardbutton. - Navigate to the
Importpage in Grafana and paste the ID into theGrafana.com dashboard URL or IDfield. - Select Datasource as prometheus
- Click on the
Loadbutton, thenImportbutton.
Here is a screenshot of the dashboard:



