A monitoring solution for NicLabs projects using Prometheus for metric storage, Grafana for visualization, and AlertManager with a Telegram Bot for alerts.
This repository also contains scripts and configuration files for the following exporters:
The monitoring server and all the exporters are run using Docker.
The monitor uses the following logical architecture:
The modules for data storage, visualization and alerting are run as separate containers on the same host machine.
The exporters can be run on however many machines are necessary, they're only required to be accessible from the Prometheus Server
container through an HTTP GET request.
Each exporter has a directory under the Exporters
directory. Each individual directory has a run.sh
script to run, start, stop, restart and delete the appropriate exporter's container, as well as it's configuration files when necessary.
You can also control many exporters at once using the run.sh
script located directly under the Exporters
directory. This script has the following usage syntax:
./run.sh [run | start | stop | restart | delete] [exporter list]
Where exporter list
is a comma separated list which can contain cadvisor
,blackbox
,nginx
,node
,postgres
, or simply all
if you want to use all of them.
For example, if you want to run the nginx and Postgres exporters simply run:
./run.sh run nginx,postgres
The server is controlled by the run.sh
script from the Server
directory.
To deploy the server:
- Configure the AlertManager:
- Configure the telegram bot editing the
config.yaml
file underprometheus_bot
and adding the correct telegram token. - Edit the
config.yml
file underAlertManager
and add the bot's IP address and telegram chatID.
- Configure the telegram bot editing the
- Configure the Grafana Server:
- Go to the
dashboards
directory and place a separatejson
file for every dashboard you wish to automatically import to grafana. The repository contains many example dashboards which use the repository's exporters (based on the dashboards from https://github.com/stefanprodan/dockprom), you should delete the ones you don't want before running the monitor.
- Go to the
- Configure the Prometheus Server:
- Edit the
prometheus.yml
under theprometheus
directory to set which exporters prometheus will scrape for metrics. The repository contains an example configuration you can use to scrape every exporter from theExporters
directory. - Edit the
.rules
files under theprometheus
directory to define under which conditions the AlertManager should be notified. You can use the files included in this repository as an example.
- Edit the
- Run the
run.sh
under theServer
directory to manage the server's containers.
The run.sh
script has the following usage:
./run.sh [run | start | stop | restart | delete]
Use:
./run.sh run
To create and start all the containers. This will create a storage
directory which contains the prometheus database.