This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
prometheus [2021/10/11 05:56] – vissie | prometheus [2021/10/18 03:47] (current) – vissie | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | =====The order of things===== | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | - Install/ | ||
+ | - Install/ | ||
+ | - Install/ | ||
+ | - Install/ | ||
+ | - Install/ | ||
+ | |||
+ | |||
=====Create rules===== | =====Create rules===== | ||
sudo vim / | sudo vim / | ||
Line 4: | Line 16: | ||
| | ||
+ | =====Blackbox Exporter===== | ||
+ | Blackbox Exporter by Prometheus allows probing over endpoints such as http, https, icmp, tcp and dns | ||
+ | |||
+ | ====Install the Blackbox Exporter==== | ||
+ | https:// | ||
+ | |||
+ | sudo useradd --no-create-home --shell /bin/false blackbox_exporter | ||
+ | wget https:// | ||
+ | aunpack ./ | ||
+ | sudo cp blackbox_exporter-0.19.0.linux-amd64/ | ||
+ | sudo chown blackbox_exporter: | ||
+ | rm -rf blackbox_exporter-0.19.0.linux-amd64* | ||
+ | # Config | ||
+ | sudo mkdir / | ||
+ | sudo vim / | ||
+ | <sxh bash; gutter: false> | ||
+ | modules: | ||
+ | http_2xx: | ||
+ | prober: http | ||
+ | timeout: 5s | ||
+ | http: | ||
+ | valid_status_codes: | ||
+ | method: GET | ||
+ | preferred_ip_protocol: | ||
+ | </ | ||
+ | | ||
+ | sudo chown blackbox_exporter: | ||
+ | sudo vim / | ||
+ | <sxh bash; gutter: false> | ||
+ | [Unit] | ||
+ | Description=Blackbox Exporter | ||
+ | Wants=network-online.target | ||
+ | After=network-online.target | ||
+ | |||
+ | [Service] | ||
+ | User=blackbox_exporter | ||
+ | Group=blackbox_exporter | ||
+ | Type=simple | ||
+ | ExecStart=/ | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=multi-user.target | ||
+ | </ | ||
+ | |||
+ | sudo systemctl daemon-reload | ||
+ | sudo systemctl start blackbox_exporter | ||
+ | sudo systemctl enable blackbox_exporter | ||
+ | ====Configure Prometheus==== | ||
+ | Next, we need to provide context to prometheus on what to monitor. We will inform prometheus to monitor a web endpoint on port 8080 using the blackbox exporter (we will create a python simplehttpserver to run on port 8080). | ||
+ | Edit the prometheus config / | ||
+ | sudo vim / | ||
+ | <sxh bash; gutter: false> | ||
+ | - job_name: ' | ||
+ | metrics_path: | ||
+ | params: | ||
+ | module: [http_2xx] | ||
+ | static_configs: | ||
+ | - targets: | ||
+ | - http:// | ||
+ | relabel_configs: | ||
+ | - source_labels: | ||
+ | target_label: | ||
+ | - source_labels: | ||
+ | target_label: | ||
+ | - target_label: | ||
+ | replacement: | ||
+ | </ | ||
+ | | ||
+ | Open a new terminal, create a index.html: | ||
+ | sudo pip3 install simple_http_server | ||
+ | echo " | ||
+ | python -m SimpleHTTPServer 8080 or | ||
+ | python3 -m http.server 8080 | ||
+ | |||
+ | | ||
+ | Head back to the previous terminal session and restart prometheus: | ||
+ | sudo systemctl restart prometheus | ||
+ | | ||
+ | ====Configure the Alarm definition: | ||
+ | sudo vim / | ||
+ | <sxh bash; gutter: false> | ||
+ | groups: | ||
+ | - name: alert.rules | ||
+ | rules: | ||
+ | - alert: EndpointDown | ||
+ | expr: probe_success == 0 | ||
+ | for: 10s | ||
+ | labels: | ||
+ | severity: " | ||
+ | annotations: | ||
+ | summary: " | ||
+ | </ | ||
+ | | ||
+ | sudo chown prometheus: | ||
+ | promtool check rules / | ||
+ | sudo systemctl restart prometheus | ||
=====Setup Alert Manager===== | =====Setup Alert Manager===== | ||
# Create the user for alertmanager | # Create the user for alertmanager | ||
Line 36: | Line 144: | ||
## Access alertmanager on your endpoint on port 9093 | ## Access alertmanager on your endpoint on port 9093 | ||
| | ||
- | | + | To Debug: |
- | | + | |
+ | |||
+ | =====Telegram Bot for Alertmanager===== | ||
+ | https:// | ||
+ | sudo pip3 install -r ./ | ||
+ | sudo pip3 install python-dateutil | ||
+ | |||
+ | |||
+ | =====Issues===== | ||
+ | ====ICMP==== | ||
+ | To get ping [icmp] to work, I had to do the following: | ||
+ | sudo setcap cap_net_raw+ep / | ||
+ |