mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2024-11-14 10:04:46 +08:00
Make http_host_bind_port vars more useful (#1984)
* if variable to bind an exporter container to a host port is set, have matrix-domain.conf (nginx) support this * manipulate some variables to account for just port numbers or 0.0.0.0 IPs * Make sure to use the right variable in the init.yml files * Update roles/matrix-prometheus-node-exporter/tasks/init.yml Co-authored-by: Slavi Pantaleev <slavi@devture.com> * Update roles/matrix-prometheus-postgres-exporter/tasks/init.yml Co-authored-by: Slavi Pantaleev <slavi@devture.com> * remove extraneous variables and whitespace Co-authored-by: Luca Bilke <luca@gmail.com> Co-authored-by: Slavi Pantaleev <slavi@devture.com>
This commit is contained in:
parent
d65096cd82
commit
c77f2b8a64
@ -38,7 +38,7 @@ matrix_prometheus_node_exporter_metrics_proxying_enabled: false
|
||||
|
||||
# Controls whether the matrix-prometheus container exposes its HTTP port (tcp/9100 in the container).
|
||||
#
|
||||
# Takes an "<ip>:<port>" value (e.g. "127.0.0.1:9100"), or empty string to not expose.
|
||||
# Takes an "<ip>:<port>" value (e.g. "127.0.0.1:9100"), just a port number or empty string to not expose.
|
||||
#
|
||||
# You likely don't need to do this. See `matrix_prometheus_node_exporter_metrics_proxying_enabled`.
|
||||
#
|
||||
@ -54,3 +54,9 @@ matrix_prometheus_node_exporter_metrics_proxying_enabled: false
|
||||
# because node-exporter can't see all interfaces, etc.
|
||||
# For now, we'll live with that, until someone develops a better solution.
|
||||
matrix_prometheus_node_exporter_container_http_host_bind_port: ''
|
||||
|
||||
# If you are supplying your own NGINX proxy but want to use the provided exporters you will have to supply an "<ip>:<port>" value for the containers to bind to on your host.
|
||||
# If matrix_prometheus_node_exporter_container_http_host_bind_port is set to just a port number, this will default to "127.0.0.1:<port>"
|
||||
# If matrix_prometheus_node_exporter_container_http_host_bind_port is set to an IP that is not 0.0.0.0 and a port, that "<ip>:<port>" value will be used
|
||||
# Otherwise this value will be empty and you will have to manually configure your NGINX config file. (If you are using the config files generated by this playbook, you will have to edit matrix-domain.conf)
|
||||
matrix_prometheus_node_exporter_matrix_nginx_proxy_not_enabled_proxy_pass_host: "{{ '127.0.0.1' + matrix_prometheus_node_exporter_container_http_host_bind_port_number_raw if not ':' in matrix_prometheus_node_exporter_container_http_host_bind_port else (matrix_prometheus_node_exporter_container_http_host_bind_port if matrix_prometheus_node_exporter_container_http_host_bind_port.split(':')[0] != '0.0.0.0' else '') }}"
|
||||
|
@ -23,10 +23,10 @@
|
||||
resolver 127.0.0.11 valid=5s;
|
||||
set $backend "matrix-prometheus-node-exporter:9100";
|
||||
proxy_pass http://$backend/metrics;
|
||||
{% elif matrix_prometheus_node_exporter_matrix_nginx_proxy_not_enabled_proxy_pass_host != '' %}
|
||||
proxy_pass http://{{ matrix_prometheus_node_exporter_matrix_nginx_proxy_not_enabled_proxy_pass_host }}/metrics;
|
||||
{% else %}
|
||||
{# Generic configuration for use outside of our container setup #}
|
||||
{# This may be implemented in the future. #}
|
||||
return 404 "matrix-nginx-proxy is disabled, so metrics are unavailable";
|
||||
return 404 "matrix-nginx-proxy is disabled and no host port was bound to the container, so metrics are unavailable";
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
|
5
roles/matrix-prometheus-node-exporter/vars/main.yml
Normal file
5
roles/matrix-prometheus-node-exporter/vars/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
# `matrix_prometheus_node_exporter_container_http_host_bind_port_number_raw` contains the raw port number extracted from `matrix_prometheus_node_exporter_container_http_host_bind_port`,
|
||||
# which can contain values like this: ('1234', '127.0.0.1:1234', '0.0.0.0:1234')
|
||||
matrix_prometheus_node_exporter_container_http_host_bind_port_number_raw: "{{ '' if matrix_prometheus_node_exporter_container_http_host_bind_port == '' else (matrix_prometheus_node_exporter_container_http_host_bind_port.split(':')[1] if ':' in matrix_prometheus_node_exporter_container_http_host_bind_port else matrix_prometheus_node_exporter_container_http_host_bind_port) }}"
|
@ -35,7 +35,7 @@ matrix_prometheus_postgres_exporter_metrics_proxying_enabled: false
|
||||
|
||||
# Controls whether the matrix-prometheus container exposes its HTTP port (tcp/9187 in the container).
|
||||
#
|
||||
# Takes an "<ip>:<port>" value (e.g. "127.0.0.1:9187"), or empty string to not expose.
|
||||
# Takes an "<ip>:<port>" value (e.g. "127.0.0.1:9187"), just a port number or an empty string to not expose.
|
||||
#
|
||||
# You likely don't need to do this. See `matrix_prometheus_postgres_exporter_metrics_proxying_enabled`.
|
||||
#
|
||||
@ -52,5 +52,11 @@ matrix_prometheus_postgres_exporter_metrics_proxying_enabled: false
|
||||
# For now, we'll live with that, until someone develops a better solution.
|
||||
matrix_prometheus_postgres_exporter_container_http_host_bind_port: ''
|
||||
|
||||
# If you are supplying your own NGINX proxy but want to use the provided exporters you will have to supply an "<ip>:<port>" value for the containers to bind to on your host.
|
||||
# If matrix_prometheus_postgres_exporter_container_http_host_bind_port is set to just a port number, this will default to "127.0.0.1:<port>"
|
||||
# If matrix_prometheus_postgres_exporter_container_http_host_bind_port is set to an IP that is not 0.0.0.0 and a port, that "<ip>:<port>" value will be used
|
||||
# Otherwise this value will be empty and you will have to manually configure your NGINX config file. (If you are using the config files generated by this playbook, you will have to edit matrix-domain.conf)
|
||||
matrix_prometheus_postgres_exporter_matrix_nginx_proxy_not_enabled_proxy_pass_host: "{{ '127.0.0.1' + matrix_prometheus_postgres_exporter_container_http_host_bind_port_number_raw if not ':' in matrix_prometheus_postgres_exporter_container_http_host_bind_port else (matrix_prometheus_postgres_exporter_container_http_host_bind_port if matrix_prometheus_postgres_exporter_container_http_host_bind_port.split(':')[0] != '0.0.0.0' else '') }}"
|
||||
|
||||
matrix_prometheus_postgres_exporter_dashboard_urls:
|
||||
- "https://grafana.com/api/dashboards/9628/revisions/7/download"
|
||||
|
@ -23,10 +23,10 @@
|
||||
resolver 127.0.0.11 valid=5s;
|
||||
set $backend "matrix-prometheus-postgres-exporter:9187";
|
||||
proxy_pass http://$backend/metrics;
|
||||
{% elif matrix_prometheus_postgres_exporter_matrix_nginx_proxy_not_enabled_proxy_pass_host != '' %}
|
||||
proxy_pass http://{{ matrix_prometheus_postgres_exporter_matrix_nginx_proxy_not_enabled_proxy_pass_host }}/metrics;
|
||||
{% else %}
|
||||
{# Generic configuration for use outside of our container setup #}
|
||||
{# This may be implemented in the future. #}
|
||||
return 404 "matrix-nginx-proxy is disabled, so metrics are unavailable";
|
||||
return 404 "matrix-nginx-proxy is disabled and no host port was bound to the container, so metrics are unavailable";
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
|
5
roles/matrix-prometheus-postgres-exporter/vars/main.yml
Normal file
5
roles/matrix-prometheus-postgres-exporter/vars/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
# `matrix_prometheus_postgres_exporter_container_http_host_bind_port_number_raw` contains the raw port number extracted from `matrix_prometheus_postgres_exporter_container_http_host_bind_port`,
|
||||
# which can contain values like this: ('1234', '127.0.0.1:1234', '0.0.0.0:1234')
|
||||
matrix_prometheus_postgres_exporter_container_http_host_bind_port_number_raw: "{{ '' if matrix_prometheus_postgres_exporter_container_http_host_bind_port == '' else (matrix_prometheus_postgres_exporter_container_http_host_bind_port.split(':')[1] if ':' in matrix_prometheus_postgres_exporter_container_http_host_bind_port else matrix_prometheus_postgres_exporter_container_http_host_bind_port) }}"
|
Loading…
Reference in New Issue
Block a user