Skip to content

Commit 972ee8f

Browse files
Monitoring: add victoriametrics (#198)
* change docker handler to module * add victoriametrics and blackbox exporter * basic blackbox exporter config * fix helpers after meshviewer update * add victoriatraces
1 parent 2ce93a7 commit 972ee8f

File tree

7 files changed

+130
-17
lines changed

7 files changed

+130
-17
lines changed

roles/docker/handlers/main.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
- name: Run docker-compose # noqa: no-changed-when
3-
ansible.builtin.command:
4-
cmd: docker compose --project-directory /etc/freifunk/ up --detach --force-recreate --remove-orphans --wait --quiet-pull --pull always
3+
community.docker.docker_compose_v2:
4+
project_src: /etc/freifunk/
5+
pull: always
6+
recreate: always
7+
remove_orphans: true
8+
wait: true
59

610
# vim: set filetype=yaml:

roles/docker/templates/monitor.berlin.freifunk.net.yml.j2

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,56 @@ services:
88
- 127.0.0.1:25827:25826/udp
99
command: --collectd.listen-address=":25826"
1010

11+
pushgateway:
12+
restart: unless-stopped
13+
image: prom/pushgateway:v1.11.2
14+
ports:
15+
- 127.0.0.1:9091:9091
16+
17+
blackbox:
18+
restart: unless-stopped
19+
image: prom/blackbox-exporter:v0.28.0
20+
# network: host to allow V6 ping
21+
network_mode: host
22+
command:
23+
- '--config.file=/etc/blackbox/blackbox.yml'
24+
volumes:
25+
- /etc/freifunk/blackbox.yml:/etc/blackbox/blackbox.yml
26+
27+
victoriametrics:
28+
restart: unless-stopped
29+
image: victoriametrics/victoria-metrics:v1.135.0
30+
ports:
31+
- 8428:8428
32+
- 8089:8089
33+
- 8089:8089/udp
34+
- 4242:4242
35+
command:
36+
- '--retentionPeriod=365'
37+
- '--storageDataPath=/victoria-metrics-data'
38+
- '--httpListenAddr=:8428'
39+
- '--influxListenAddr=:8089'
40+
volumes:
41+
- /mnt/victoriametrics/data:/victoria-metrics-data
42+
43+
victorialogs:
44+
restart: unless-stopped
45+
image: victoriametrics/victoria-logs:v1.44.0
46+
ports:
47+
- 9428:9428
48+
command:
49+
- '--retentionPeriod=7d'
50+
- '--storageDataPath=/victoria-logs-data'
51+
volumes:
52+
- /mnt/victorialogs/data:/victoria-logs-data
53+
54+
victoriatraces:
55+
image: 'docker.io/victoriametrics/victoria-traces:v0.7.1'
56+
ports:
57+
- "10428:10428"
58+
command:
59+
- "--storageDataPath=/vtraces"
60+
volumes:
61+
- /mnt/victoriatraces/data:/vtraces
62+
1163
# vim: set filetype=yaml:

roles/ff_monitor/files/create_node_geojson.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import urllib.request
44
import requests
55

6-
PROMETHEUS_HOST="localhost:9090"
6+
PROMETHEUS_HOST="localhost:8428"
77

8-
dhcp_leases=requests.get('http://localhost:9090/api/v1/query', params={'query': 'collectd_dhcpleases_count{}'})
8+
dhcp_leases=requests.get(f'http://{PROMETHEUS_HOST}/api/v1/query', params={'query': 'collectd_dhcpleases_count{}'}, timeout=30)
99

1010
LEASES_DICT = dict()
1111

@@ -15,8 +15,7 @@
1515
LEASES_DICT[node_name] = leases
1616

1717

18-
19-
with urllib.request.urlopen("https://hopglass.berlin.freifunk.net/nodes.json") as url:
18+
with urllib.request.urlopen("https://hopglass.berlin.freifunk.net/meshviewer.json") as url:
2019
data = json.loads(url.read().decode())
2120

2221
simplenodelist = list()
@@ -26,11 +25,11 @@
2625
simplenode = {"type": "Feature"}
2726

2827
properties = {}
29-
geometry = {'type': "Point", 'coordinates': [node['nodeinfo']['location']['longitude'],
30-
node['nodeinfo']['location']['latitude']]}
28+
geometry = {'type': "Point", 'coordinates': [node['location']['longitude'],
29+
node['location']['latitude']]}
3130

32-
properties['name'] = node['nodeinfo']['hostname']
33-
properties['leases'] = LEASES_DICT.get(node['nodeinfo']['hostname'], 0)
31+
properties['name'] = node['hostname']
32+
properties['leases'] = LEASES_DICT.get(node['hostname'], 0)
3433

3534
simplenode['properties'] = properties
3635
simplenode['geometry'] = geometry

roles/ff_monitor/files/create_node_list.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
import json
33
import urllib.request
44

5-
with urllib.request.urlopen("https://hopglass.berlin.freifunk.net/nodes.json") as url:
5+
with urllib.request.urlopen("https://hopglass.berlin.freifunk.net/meshviewer.json") as url:
66
data = json.loads(url.read().decode())
77

88
simplenodelist = list()
99

1010
nodes = data.get("nodes")
1111
for node in nodes:
1212
simplenode = {
13-
"latitude": node["nodeinfo"]["location"]["latitude"],
14-
"longitude": node["nodeinfo"]["location"]["longitude"],
15-
"name": node["nodeinfo"]["hostname"],
16-
"key": node["nodeinfo"]["hostname"],
13+
"latitude": node["location"]["latitude"],
14+
"longitude": node["location"]["longitude"],
15+
"name": node["hostname"],
16+
"key": node["hostname"],
1717
}
1818
simplenodelist.append(simplenode.copy())
1919

roles/ff_monitor/tasks/main.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,11 @@
125125
mode: "0644"
126126
owner: www-data
127127
group: www-data
128+
129+
- name: Add blackbox exporter config
130+
ansible.builtin.template:
131+
dest: /etc/freifunk/blackbox.yml
132+
src: blackbox.yml.j2
133+
mode: "0644"
134+
owner: root
135+
group: root
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
modules:
3+
icmp:
4+
prober: icmp
5+
timeout: 5s
6+
7+
# vim: set filetype=yaml:

roles/ff_monitor/templates/prometheus.yml.j2

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
---
12
global:
23
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
34
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
45

6+
# Also write to Victoriametrics
7+
remote_write:
8+
- url: http://localhost:8428/api/v1/write
9+
510
alerting:
611
alertmanagers:
712
- static_configs:
@@ -24,7 +29,7 @@ scrape_configs:
2429
scrape_interval: 5s
2530
scrape_timeout: 5s
2631
static_configs:
27-
- targets: ['localhost:9090']
32+
- targets: ['localhost:9090', 'localhost:9115']
2833

2934
- job_name: 'pushgateway'
3035
scrape_interval: 30s
@@ -49,7 +54,7 @@ scrape_configs:
4954
- "a36s-cr1.berlin.freifunk.net:9100"
5055
- "a36s-cr2.berlin.freifunk.net:9100"
5156
- "l105-cr1.berlin.freifunk.net:9100"
52-
{% for host in groups.all %}
57+
{% for host in groups.all | sort %}
5358
- "{{ host }}:9100"
5459
{% endfor %}
5560

@@ -58,3 +63,41 @@ scrape_configs:
5863
scrape_timeout: 30s
5964
static_configs:
6065
- targets: ['127.0.0.1:9111']
66+
67+
- job_name: 'blackbox-ping'
68+
metrics_path: /probe
69+
params:
70+
module: [icmp]
71+
static_configs:
72+
- targets:
73+
# quad9
74+
- 9.9.9.9
75+
- 149.112.112.112
76+
- 2620:fe::fe
77+
- 2620:fe::9
78+
# cloudflare
79+
- 1.1.1.1
80+
- 1.0.0.1
81+
- 2606:4700:4700::1111
82+
- 2606:4700:4700::1001
83+
84+
relabel_configs:
85+
- source_labels: [__address__]
86+
target_label: __param_target
87+
- source_labels: [__param_target]
88+
target_label: instance
89+
- target_label: __address__
90+
replacement: localhost:9115
91+
92+
93+
- job_name: victoriametrics
94+
static_configs:
95+
- targets:
96+
- localhost:8428
97+
98+
- job_name: victorialogs
99+
static_configs:
100+
- targets:
101+
- localhost:9428
102+
103+
# vim: set filetype=yaml:

0 commit comments

Comments
 (0)