diff --git a/Readme.md b/Readme.md index 9def8cb..b971e6e 100644 --- a/Readme.md +++ b/Readme.md @@ -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. -``` \ No newline at end of file +``` + +### Prometheus + +Prometheus is a system for monitoring and alerting. To install it run `prometheus./install.sh`. + +Prometheus server will listen on port `:9090` \ No newline at end of file diff --git a/prometheus/install.sh b/prometheus/install.sh new file mode 100644 index 0000000..85e7cce --- /dev/null +++ b/prometheus/install.sh @@ -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 + diff --git a/prometheus/prometheus.service b/prometheus/prometheus.service new file mode 100644 index 0000000..2a185a1 --- /dev/null +++ b/prometheus/prometheus.service @@ -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 \ No newline at end of file diff --git a/prometheus/prometheus.yml b/prometheus/prometheus.yml new file mode 100644 index 0000000..fd4072b --- /dev/null +++ b/prometheus/prometheus.yml @@ -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=` 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=` to any timeseries scraped from this config. + - job_name: "sensors" + metrics_path: "/" + static_configs: + - targets: ["localhost:8000"] \ No newline at end of file