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

development
Slavi Pantaleev 4 years ago
parent 6842102e00
commit c8ab200cb1

@ -1405,6 +1405,10 @@ matrix_prometheus_enabled: false
# Prometheus' HTTP port to the local host. # 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_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 }}" matrix_prometheus_scraper_node_enabled: "{{ matrix_prometheus_node_exporter_enabled }}"
###################################################################### ######################################################################

@ -6,8 +6,6 @@ matrix_prometheus_enabled: false
matrix_prometheus_docker_image: "docker.io/prom/prometheus:v2.24.1" matrix_prometheus_docker_image: "docker.io/prom/prometheus:v2.24.1"
matrix_prometheus_docker_image_force_pull: "{{ matrix_prometheus_docker_image.endswith(':latest') }}" 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_base_path: "{{ matrix_base_data_path }}/prometheus"
matrix_prometheus_config_path: "{{ matrix_prometheus_base_path }}/config" matrix_prometheus_config_path: "{{ matrix_prometheus_base_path }}/config"
matrix_prometheus_data_path: "{{ matrix_prometheus_base_path }}/data" 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. # 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: '' 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. # Tells whether the "node" scraper configuration is enabled.
# This configuration aims to scrape the current node (this server). # This configuration aims to scrape the current node (this server).
matrix_prometheus_scraper_node_enabled: false matrix_prometheus_scraper_node_enabled: false

@ -34,22 +34,24 @@
matrix_prometheus_scraper_node_targets: ["{{ matrix_docker_network_info.network.IPAM.Config[0].Gateway }}:9100"] 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" when: "matrix_prometheus_scraper_node_enabled|bool and matrix_prometheus_scraper_node_targets|length == 0"
- name: Ensure prometheus.yml installed
copy:
content: "{{ matrix_prometheus_configuration|to_nice_yaml }}"
dest: "{{ matrix_prometheus_config_path }}/prometheus.yml"
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Download synapse-v2.rules - name: Download synapse-v2.rules
get_url: get_url:
url: "{{ matrix_synapse_prometheus_rules_download_url }}" url: "{{ matrix_prometheus_scraper_synapse_rules_download_url }}"
dest: "{{ matrix_prometheus_config_path }}/synapse-v2.rules" dest: "{{ matrix_prometheus_config_path }}/synapse-v2.rules"
force: true force: true
mode: 0440 mode: 0440
owner: "{{ matrix_user_username }}" owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}" 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 }}"
dest: "{{ matrix_prometheus_config_path }}/prometheus.yml"
mode: 0644
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
- name: Ensure matrix-prometheus.service installed - name: Ensure matrix-prometheus.service installed
template: template:

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

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

Loading…
Cancel
Save