Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
ccaf358904 | |||
5353f5de1d | |||
2f5cdf49b0 | |||
757c460be5 | |||
7033a7f74f | |||
09144c5d64 |
7 changed files with 107 additions and 20 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
data/*
|
23
README.md
23
README.md
|
@ -1,2 +1,23 @@
|
|||
# mon-test
|
||||
# cyber-gov backend?
|
||||
|
||||
Simple Prometheus setup for monitoring websites, with blackbox-exporter and Grafana.
|
||||
|
||||
Testing data source for target discovery is located in branch `pages` and is served on `https://mdivecky.nolog.page/mon-test/targets.json`
|
||||
|
||||
|
||||
# Setup
|
||||
|
||||
```bash
|
||||
mkdir -p ./data/prometheus
|
||||
mkdir -p ./data/grafana
|
||||
chown -R 1000:1000 ./data/*
|
||||
# Or switch to docker volumes for prometheus and Grafana, if you don't want to deal with permissions
|
||||
|
||||
docker compose up -d
|
||||
|
||||
# -> Goto http://localhost:3000
|
||||
# Login to Grafana with admin:admin
|
||||
# Add Prometheus datasource, with URL "http://prometheus:9090"
|
||||
# Import or create some dashboards
|
||||
# Profit $$$
|
||||
```
|
52
compose.yml
Normal file
52
compose.yml
Normal file
|
@ -0,0 +1,52 @@
|
|||
|
||||
services:
|
||||
blackbox:
|
||||
image: prom/blackbox-exporter:latest
|
||||
command:
|
||||
- --config.file=/etc/blackbox/blackbox.yml
|
||||
volumes:
|
||||
- ./config/blackbox:/etc/blackbox
|
||||
ports:
|
||||
- 127.0.0.1:9115:9115 # Debug only
|
||||
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
user: 1000:1000
|
||||
ports:
|
||||
- 127.0.0.1:9094:9090 # Debug only
|
||||
volumes:
|
||||
- ./config/prometheus:/etc/prometheus
|
||||
- ./data/prometheus:/prometheus
|
||||
command: --web.enable-lifecycle --web.enable-remote-write-receiver --config.file=/etc/prometheus/prometheus.yml
|
||||
restart: unless-stopped
|
||||
|
||||
grafana:
|
||||
image: grafana/grafana-oss:latest
|
||||
restart: unless-stopped
|
||||
user: 1000:1000
|
||||
environment:
|
||||
GF_DATABASE_TYPE: postgres
|
||||
GF_DATABASE_HOST: grafana_db:5432
|
||||
GF_DATABASE_NAME: grafana
|
||||
GF_DATABASE_USER: grafana
|
||||
GF_DATABASE_PASSWORD: grafana
|
||||
GF_DATABASE_SSL_MODE: disable
|
||||
#GF_SERVER_ROOT_URL: "https://grafana.druit.org/"
|
||||
depends_on:
|
||||
- grafana_db
|
||||
ports:
|
||||
- 3000:3000
|
||||
volumes:
|
||||
- ./data/grafana:/var/lib/grafana
|
||||
# - ./config/grafana/provisioning:/etc/grafana/provisioning
|
||||
# - ./config/grafana/dashboards:/var/lib/grafana/dashboards
|
||||
|
||||
grafana_db:
|
||||
image: postgres:15
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_DB: grafana
|
||||
POSTGRES_USER: grafana
|
||||
POSTGRES_PASSWORD: grafana
|
||||
volumes:
|
||||
- ./data/grafana-db:/var/lib/postgresql/data
|
8
config/blackbox/blackbox.yml
Normal file
8
config/blackbox/blackbox.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
modules:
|
||||
http_2xx:
|
||||
prober: http
|
||||
timeout: 60s
|
||||
http:
|
||||
method: GET
|
||||
valid_http_versions: ["HTTP/1.1", "HTTP/2.0"]
|
||||
preferred_ip_protocol: "ip4"
|
24
config/prometheus/prometheus.yml
Normal file
24
config/prometheus/prometheus.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
global:
|
||||
scrape_interval: 20s
|
||||
scrape_timeout: 10s
|
||||
evaluation_interval: 20s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: 'blackbox/primary'
|
||||
metrics_path: /probe
|
||||
scrape_interval: 60s
|
||||
scrape_timeout: 45s
|
||||
params:
|
||||
module: [http_2xx]
|
||||
http_sd_configs:
|
||||
- url: https://mdivecky.nolog.page/mon-test/targets.json
|
||||
refresh_interval: 600s
|
||||
relabel_configs:
|
||||
- source_labels: [check_url]
|
||||
target_label: __address__
|
||||
- source_labels: [__address__]
|
||||
target_label: __param_target
|
||||
- source_labels: [__param_target]
|
||||
target_label: instance
|
||||
- target_label: __address__
|
||||
replacement: blackbox:9115
|
|
@ -1 +0,0 @@
|
|||
Hello, testing pages
|
18
targets.json
18
targets.json
|
@ -1,18 +0,0 @@
|
|||
[
|
||||
{
|
||||
"targets": [
|
||||
"nolog.cz"
|
||||
],
|
||||
"labels": {
|
||||
"check_url": "http://nolog.cz/"
|
||||
}
|
||||
},
|
||||
{
|
||||
"targets": [
|
||||
"cyberladies.cz"
|
||||
],
|
||||
"labels": {
|
||||
"check_url": "https://www.cyberladies.cz/"
|
||||
}
|
||||
}
|
||||
]
|
Loading…
Reference in a new issue