Add prometheus support

This commit is contained in:
Denis-Cosmin Nutiu 2022-06-13 14:00:45 +03:00
parent 1bd74683dc
commit 1731ecb5c3
4 changed files with 67 additions and 1 deletions

View file

@ -70,4 +70,10 @@ sudo systemctl status bme680-homekit
└─1722 /usr/bin/python3 /home/pi/bme680-homekit/main.py
Feb 21 20:10:30 raspberrypi systemd[1]: Started Bme680 Homekit service.
```
```
### Prometheus
Prometheus is a system for monitoring and alerting. To install it run `prometheus./install.sh`.
Prometheus server will listen on port `:9090`

9
prometheus/install.sh Normal file
View file

@ -0,0 +1,9 @@
wget https://github.com/prometheus/prometheus/releases/download/v2.36.1/prometheus-2.36.1.linux-armv6.tar.gz
tar -xzvf prometheus-2.36.1.linux-armv6.tar.gz
rm prometheus-2.36.1.linux-armv6.tar.gz
cp prometheus.service /etc/systemd/system
systemctl daemon-reload
systemctl start prometheus
systemctl enable prometheus

View file

@ -0,0 +1,17 @@
[Unit]
Description=Prometheus Server
Documentation=https://prometheus.io/docs/introduction/overview/
After=network-online.target
[Service]
Restart=on-failure
RestartSec=5s
User=pi
Restart=on-failure
ExecStart=/home/pi/bme680-homekit/prometheus/prometheus-2.36.1.linux-armv6/prometheus \
--config.file=/home/pi/bme680-homekit/prometheus/prometheus.yml \
--storage.tsdb.path=/home/pi/bme680-homekit/prometheus/data
[Install]
WantedBy=multi-user.target

34
prometheus/prometheus.yml Normal file
View file

@ -0,0 +1,34 @@
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Alertmanager configuration
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "prometheus"
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ["localhost:9090"]
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: "sensors"
metrics_path: "/"
static_configs:
- targets: ["localhost:8000"]