diff --git a/provision-contest/ansible/roles/grafana/templates/prometheus.yml.j2 b/provision-contest/ansible/roles/grafana/templates/prometheus.yml.j2 index a28be1ca..91d8791e 100644 --- a/provision-contest/ansible/roles/grafana/templates/prometheus.yml.j2 +++ b/provision-contest/ansible/roles/grafana/templates/prometheus.yml.j2 @@ -9,91 +9,23 @@ scrape_configs: - job_name: 'prometheus' static_configs: - targets: ['localhost:9090'] - - job_name: 'db' - basic_auth: - username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" - tls_config: - insecure_skip_verify: true - scheme: https - static_configs: - - targets: -{% for host in groups["domserver"] %} - - {{ hostvars[host].ansible_host }}:9104 -{% endfor %} - - job_name: node_domserver - basic_auth: - username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" - tls_config: - insecure_skip_verify: true - scheme: https - static_configs: - - targets: -{% for host in groups["domserver"] %} - - {{ hostvars[host].ansible_host }}:9100 -{% endfor %} +{% for group_prefix in GROUP_PREFIXES %} +{% if groups[group_prefix+"judgehost"][0] is defined %} - job_name: node_judgehost basic_auth: username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" - tls_config: - insecure_skip_verify: true - scheme: https - static_configs: - - targets: -{% for host in groups["judgehost"] %} - - {{ hostvars[host].ansible_host }}:9100 -{% endfor %} - - job_name: node_grafana - basic_auth: - username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" - tls_config: - insecure_skip_verify: true - scheme: https - static_configs: - - targets: -{% for host in groups["grafana"] %} - - {{ hostvars[host].ansible_host }}:9100 -{% endfor %} - - job_name: node_mgmt - basic_auth: - username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" - tls_config: - insecure_skip_verify: true - scheme: https - static_configs: - - targets: -{% for host in groups["mgmt"] %} - - {{ hostvars[host].ansible_host }}:9100 -{% endfor %} - - job_name: node_scoreboard - basic_auth: - username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" - tls_config: - insecure_skip_verify: true - scheme: https - static_configs: - - targets: -{% for host in groups["scoreboard"] %} - - {{ hostvars[host].ansible_host }}:9100 -{% endfor %} - - job_name: node_cds - basic_auth: - username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" + password: "{{ groups[group_prefix+"judgehost"][0]['PROMETHEUS_PASS'] }}" tls_config: insecure_skip_verify: true scheme: https static_configs: - targets: -{% for host in groups["cds"] %} +{% for host in groups[group_prefix+"judgehost"] %} - {{ hostvars[host].ansible_host }}:9100 {% endfor %} - - job_name: domjudge +{% endif %} +{% if groups["domserver"][0] is defined %} + - job_name: {{ group_prefix ~ domjudge }} basic_auth: username: admin password: {{ ADMIN_PASSWORD }} @@ -103,58 +35,59 @@ scrape_configs: insecure_skip_verify: true static_configs: - targets: -{% for host in groups["domserver"] %} +{% for host in groups[group_prefix+"domserver"] %} - {{ hostvars[host].ansible_host }} {% endfor %} - - job_name: 'web_nginx_cds' + - job_name: {{ group_prefix ~ 'db' }} basic_auth: username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" + password: "{{ groups[group_prefix+"domserver"][0]['PROMETHEUS_PASS'] }}" tls_config: insecure_skip_verify: true scheme: https static_configs: - targets: -{% for host in groups["cds"] %} - - {{ hostvars[host].ansible_host }}:9113 +{% for host in groups[group_prefix+"domserver"] %} + - {{ hostvars[host].ansible_host }}:9104 {% endfor %} - - job_name: 'web_nginx_scoreboard' + - job_name: {{ group_prefix ~ 'node_domserver' }} basic_auth: username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" + password: "{{ groups[group_prefix+"domserver"][0]['PROMETHEUS_PASS'] }}" tls_config: insecure_skip_verify: true scheme: https static_configs: - targets: -{% for host in groups["scoreboard"] %} - - {{ hostvars[host].ansible_host }}:9113 +{% for host in groups["domserver"] %} + - {{ hostvars[host].ansible_host }}:9100 {% endfor %} - - job_name: 'web_nginx_domserver' + - job_name: {{ group_prefix ~ 'web_nginx_domserver' }} basic_auth: username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" + password: "{{ groups[group_prefix+"domserver"][0]['PROMETHEUS_PASS'] }}" tls_config: insecure_skip_verify: true scheme: https static_configs: - targets: -{% for host in groups["domserver"] %} +{% for host in groups[group_prefix+"domserver"] %} - {{ hostvars[host].ansible_host }}:9113 {% endfor %} - - job_name: 'web_fpm_domserver' + - job_name: {{ group_prefix ~ 'web_fpm_domserver' }} basic_auth: username: "prometheus" - password: "{{ PROMETHEUS_PASS }}" + password: "{{ groups[group_prefix+"domserver"][0]['PROMETHEUS_PASS'] }}" tls_config: insecure_skip_verify: true scheme: https static_configs: - targets: -{% for host in groups["domserver"] %} +{% for host in groups[group_prefix+"domserver"] %} - {{ hostvars[host].ansible_host }}:9253 {% endfor %} - - job_name: 'online-db' +{% endif %} + - job_name: node_grafana basic_auth: username: "prometheus" password: "{{ PROMETHEUS_PASS }}" @@ -163,10 +96,10 @@ scrape_configs: scheme: https static_configs: - targets: -{% for host in groups["online-domserver"] %} - - {{ hostvars[host].ansible_host }}:9104 +{% for host in groups["grafana"] %} + - {{ hostvars[host].ansible_host }}:9100 {% endfor %} - - job_name: node_domserver_online + - job_name: node_mgmt basic_auth: username: "prometheus" password: "{{ PROMETHEUS_PASS }}" @@ -175,23 +108,22 @@ scrape_configs: scheme: https static_configs: - targets: -{% for host in groups["online-domserver"] %} +{% for host in groups["mgmt"] %} - {{ hostvars[host].ansible_host }}:9100 {% endfor %} - - job_name: online-domjudge + - job_name: node_scoreboard basic_auth: - username: admin - password: {{ ADMIN_PASSWORD }} - metrics_path: /api/v4/metrics/prometheus - scheme: https + username: "prometheus" + password: "{{ PROMETHEUS_PASS }}" tls_config: insecure_skip_verify: true + scheme: https static_configs: - targets: -{% for host in groups["online-domserver"] %} - - {{ hostvars[host].ansible_host }} +{% for host in groups["scoreboard"] %} + - {{ hostvars[host].ansible_host }}:9100 {% endfor %} - - job_name: 'web_nginx_domserver_online' + - job_name: node_cds basic_auth: username: "prometheus" password: "{{ PROMETHEUS_PASS }}" @@ -200,10 +132,10 @@ scrape_configs: scheme: https static_configs: - targets: -{% for host in groups["online-domserver"] %} - - {{ hostvars[host].ansible_host }}:9113 +{% for host in groups["cds"] %} + - {{ hostvars[host].ansible_host }}:9100 {% endfor %} - - job_name: 'web_fpm_domserver_online' + - job_name: 'web_nginx_cds' basic_auth: username: "prometheus" password: "{{ PROMETHEUS_PASS }}" @@ -212,10 +144,10 @@ scrape_configs: scheme: https static_configs: - targets: -{% for host in groups["online-domserver"] %} - - {{ hostvars[host].ansible_host }}:9253 +{% for host in groups["cds"] %} + - {{ hostvars[host].ansible_host }}:9113 {% endfor %} - - job_name: node_judgehost_online + - job_name: 'web_nginx_scoreboard' basic_auth: username: "prometheus" password: "{{ PROMETHEUS_PASS }}" @@ -224,7 +156,6 @@ scrape_configs: scheme: https static_configs: - targets: -{% for host in groups["online-judgehost"] %} - - {{ hostvars[host].ansible_host }}:9100 +{% for host in groups["scoreboard"] %} + - {{ hostvars[host].ansible_host }}:9113 {% endfor %} -