Break dependency between matrix-prometheus and (matrix-prometheus-node-exporter, matrix-synapse)

This commit is contained in:
Slavi Pantaleev 2021-01-31 19:23:12 +02:00
parent 6842102e00
commit c8ab200cb1
5 changed files with 30 additions and 16 deletions

View file

@ -1405,6 +1405,10 @@ matrix_prometheus_enabled: false
# Prometheus' HTTP port to the local host.
matrix_prometheus_container_http_host_bind_port: "{{ '' if matrix_nginx_proxy_enabled else '127.0.0.1:9090' }}"
matrix_prometheus_scraper_synapse_enabled: "{{ matrix_synapse_enabled and matrix_synapse_metrics_enabled }}"
matrix_prometheus_scraper_synapse_targets: ['matrix-synapse:{{ matrix_synapse_metrics_port }}']
matrix_prometheus_scraper_synapse_rules_synapse_tag: "{{ matrix_synapse_docker_image_tag }}"
matrix_prometheus_scraper_node_enabled: "{{ matrix_prometheus_node_exporter_enabled }}"
######################################################################

View file

@ -6,8 +6,6 @@ matrix_prometheus_enabled: false
matrix_prometheus_docker_image: "docker.io/prom/prometheus:v2.24.1"
matrix_prometheus_docker_image_force_pull: "{{ matrix_prometheus_docker_image.endswith(':latest') }}"
matrix_synapse_prometheus_rules_download_url: "https://raw.githubusercontent.com/matrix-org/synapse/{{ matrix_synapse_docker_image_tag }}/contrib/prometheus/synapse-v2.rules"
matrix_prometheus_base_path: "{{ matrix_base_data_path }}/prometheus"
matrix_prometheus_config_path: "{{ matrix_prometheus_base_path }}/config"
matrix_prometheus_data_path: "{{ matrix_prometheus_base_path }}/data"
@ -26,6 +24,16 @@ matrix_prometheus_systemd_wanted_services_list: []
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:9090"), or empty string to not expose.
matrix_prometheus_container_http_host_bind_port: ''
# Tells whether the "synapse" scraper configuration is enabled.
matrix_prometheus_scraper_synapse_enabled: false
# Tells whether to download and load a Synapse rules file
matrix_prometheus_scraper_synapse_rules_enabled: "{{ matrix_prometheus_scraper_synapse_enabled }}"
matrix_prometheus_scraper_synapse_rules_synapse_tag: "master"
matrix_prometheus_scraper_synapse_rules_download_url: "https://raw.githubusercontent.com/matrix-org/synapse/{{ matrix_prometheus_scraper_synapse_rules_synapse_tag }}/contrib/prometheus/synapse-v2.rules"
matrix_prometheus_scraper_synapse_targets: []
# Tells whether the "node" scraper configuration is enabled.
# This configuration aims to scrape the current node (this server).
matrix_prometheus_scraper_node_enabled: false

View file

@ -34,6 +34,17 @@
matrix_prometheus_scraper_node_targets: ["{{ matrix_docker_network_info.network.IPAM.Config[0].Gateway }}:9100"]
when: "matrix_prometheus_scraper_node_enabled|bool and matrix_prometheus_scraper_node_targets|length == 0"
- name: Download synapse-v2.rules
get_url:
url: "{{ matrix_prometheus_scraper_synapse_rules_download_url }}"
dest: "{{ matrix_prometheus_config_path }}/synapse-v2.rules"
force: true
mode: 0440
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
when: "matrix_prometheus_scraper_synapse_rules_enabled|bool"
- name: Ensure prometheus.yml installed
copy:
content: "{{ matrix_prometheus_configuration|to_nice_yaml }}"
@ -42,15 +53,6 @@
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Download synapse-v2.rules
get_url:
url: "{{ matrix_synapse_prometheus_rules_download_url }}"
dest: "{{ matrix_prometheus_config_path }}/synapse-v2.rules"
force: true
mode: 0440
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-prometheus.service installed
template:
src: "{{ role_path }}/templates/systemd/matrix-prometheus.service.j2"

View file

@ -3,5 +3,5 @@
- name: Fail if Synapse metrics or Prometheus Node Exporter not enabled
fail:
msg: >
You need to enable `matrix_synapse_metrics_enabled` and/or `matrix_prometheus_node_exporter_enabled` for Prometheus grab metrics.
when: "not matrix_synapse_metrics_enabled and not matrix_prometheus_node_exporter_enabled"
You need to enable `matrix_prometheus_scraper_synapse_enabled` and/or `matrix_prometheus_scraper_node_enabled` for Prometheus grab metrics.
when: "not matrix_prometheus_scraper_synapse_enabled and not matrix_prometheus_scraper_node_enabled"

View file

@ -6,7 +6,7 @@ global:
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
{% if matrix_synapse_metrics_enabled %}
{% if matrix_prometheus_scraper_synapse_rules_enabled %}
- 'synapse-v2.rules'
{% endif %}
@ -26,11 +26,11 @@ scrape_configs:
static_configs:
- targets: ['localhost:9090']
{% if matrix_synapse_metrics_enabled %}
{% if matrix_prometheus_scraper_synapse_enabled %}
- job_name: 'synapse'
metrics_path: '/_synapse/metrics'
static_configs:
- targets: ['matrix-synapse:{{ matrix_synapse_metrics_port }}']
- targets: {{ matrix_prometheus_scraper_synapse_targets|to_json }}
{% endif %}
{% if matrix_prometheus_scraper_node_enabled %}