Skip to content

Commit 90c5005

Browse files
committed
Update metric scraping for new webservers
1 parent b96fd93 commit 90c5005

File tree

13 files changed

+132
-33
lines changed

13 files changed

+132
-33
lines changed

icpc-wf/ansible/cds.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,12 @@
2727
tags: ssh
2828
- role: cds
2929
tags: cds
30+
- role: prometheus_target_web
31+
tags: prometheus_target_web
32+
vars:
33+
MARIADB: false
34+
FPM: false
35+
when: GRAFANA_MONITORING
36+
- role: prometheus_target_all
37+
tags: prometheus_target_all
38+
when: GRAFANA_MONITORING

icpc-wf/ansible/domserver.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
when: KEEPALIVED_PRIORITY is defined
4040
- role: prometheus_target_web
4141
tags: prometheus_target_web
42+
vars:
43+
MARIADB: true
44+
FPM: true
4245
when: GRAFANA_MONITORING
4346
- role: prometheus_target_all
4447
tags: prometheus_target_all
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
grafana_port: 8443

icpc-wf/ansible/roles/grafana/handlers/main.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,25 @@
22
# Define here handlers associated to this role.
33

44
- name: restart nginx-exporter
5-
service: name=prometheus-nginx-exporter enabled=yes state=restarted
5+
service:
6+
name: prometheus-nginx-exporter
7+
enabled: true
8+
state: restarted
69

710
- name: restart php-exporter
8-
service: name=php-fpm-exporter enabled=yes state=restarted
11+
service:
12+
name: php-fpm-exporter
13+
enabled: true
14+
state: restarted
15+
16+
- name: restart nginx
17+
service:
18+
name: nginx
19+
enabled: true
20+
state: restarted
21+
22+
- name: restart grafana
23+
service:
24+
name: grafana-server
25+
enabled: true
26+
state: restarted

icpc-wf/ansible/roles/grafana/tasks/main.yml

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,49 +15,58 @@
1515
template:
1616
src: prometheus.yml.j2
1717
dest: /etc/prometheus/prometheus.yml
18-
19-
- name: restart prometheus
20-
service: name=prometheus state=restarted
18+
notify: restart prometheus
2119

2220
## Setup grafana
21+
- name: Install grafana
22+
apt:
23+
deb: https://dl.grafana.com/enterprise/release/grafana-enterprise_8.4.6_amd64.deb
24+
state: present
25+
notify: restart grafana
26+
2327
- name: configure grafana
2428
synchronize:
2529
src: files/grafana/environment
2630
dest: /etc/default/grafana-server
31+
notify: restart grafana
2732

2833
- name: set up grafana datasources
2934
synchronize:
3035
src: files/grafana/datasources.yml
3136
dest: /etc/grafana/provisioning/datasources/default.yml
37+
notify: restart grafana
3238

3339
- name: set up grafana dashboards
3440
synchronize:
3541
src: files/grafana/dashboards.yml
3642
dest: /etc/grafana/provisioning/dashboards/default.yml
43+
notify: restart grafana
3744

3845
- name: copy grafana dashboards
3946
synchronize:
4047
src: dashboards/
4148
dest: /etc/grafana/dashboards/
42-
43-
- name: restart grafana
44-
service: name=grafana-server state=restarted
49+
notify: restart grafana
4550

4651
# Setup nginx with selfsigned certificate
4752
- name: copy ssl cert
4853
synchronize:
49-
src=ssl.crt
50-
dest=/etc/ssl/certs/grafana.crt
54+
src: ssl.crt
55+
dest: /etc/ssl/certs/grafana.crt
56+
notify: restart nginx
5157

5258
- name: copy ssl key
5359
synchronize:
54-
src=ssl.key
55-
dest=/etc/ssl/private/grafana.key
60+
src: ssl.key
61+
dest: /etc/ssl/private/grafana.key
62+
notify: restart nginx
5663

5764
- name: copy default nginx config
58-
synchronize:
59-
src=nginx.conf
60-
dest=/etc/nginx/sites-enabled/grafana.conf
65+
template:
66+
src: nginx.conf.j2
67+
dest: /etc/nginx/sites-enabled/grafana.conf
68+
owner: root
69+
group: root
70+
mode: 0644
71+
notify: restart nginx
6172

62-
- name: restart nginx
63-
service: name=nginx enabled=yes state=restarted

icpc-wf/ansible/roles/grafana/templates/prometheus.yml.j2

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ global:
33
evaluation_interval: 15s # By default, scrape targets every 15 seconds.
44
# scrape_timeout is set to the global default (10s).
55
scrape_configs:
6+
- job_name: 'grafana'
7+
static_configs:
8+
- targets: ['localhost:443']
69
- job_name: 'prometheus'
710
static_configs:
811
- targets: ['localhost:9090']
@@ -29,6 +32,24 @@ scrape_configs:
2932
- targets:
3033
{% for host in groups["grafana"] %}
3134
- {{ hostvars[host].ansible_host }}:9100
35+
{% endfor %}
36+
- job_name: node_mgmt
37+
static_configs:
38+
- targets:
39+
{% for host in groups["mgmt"] %}
40+
- {{ hostvars[host].ansible_host }}:9100
41+
{% endfor %}
42+
- job_name: node_scoreboard
43+
static_configs:
44+
- targets:
45+
{% for host in groups["scoreboard"] %}
46+
- {{ hostvars[host].ansible_host }}:9100
47+
{% endfor %}
48+
- job_name: node_cds
49+
static_configs:
50+
- targets:
51+
{% for host in groups["cds"] %}
52+
- {{ hostvars[host].ansible_host }}:9100
3253
{% endfor %}
3354
- job_name: domjudge
3455
basic_auth:
@@ -42,6 +63,18 @@ scrape_configs:
4263
- targets:
4364
{% for host in groups["domserver"] %}
4465
- {{ hostvars[host].ansible_host }}
66+
{% endfor %}
67+
- job_name: 'nginx_cds'
68+
static_configs:
69+
- targets:
70+
{% for host in groups["cds"] %}
71+
- {{ hostvars[host].ansible_host }}:9113
72+
{% endfor %}
73+
- job_name: 'nginx_scoreboard'
74+
static_configs:
75+
- targets:
76+
{% for host in groups["scoreboard"] %}
77+
- {{ hostvars[host].ansible_host }}:9113
4578
{% endfor %}
4679
- job_name: 'nginx_domjudge'
4780
static_configs:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.yml

icpc-wf/ansible/roles/prometheus_target_web/files/nginx-status.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
server {
2-
listen 8080;
3-
listen [::]:8080;
2+
listen 8787;
3+
listen [::]:8787;
44
server_name _default_;
55

66
location = /basic_status {

icpc-wf/ansible/roles/prometheus_target_web/handlers/main.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
---
2-
# Define here handlers associated to this role.
3-
42
- name: restart php-exporter
53
service: name=php-fpm-exporter enabled=yes state=restarted
64

0 commit comments

Comments
 (0)