Add metrics-exposure support for Dendrite

This commit is contained in:
Slavi Pantaleev 2024-01-11 12:02:15 +02:00
parent f257cd9fbe
commit c4d6144bb9
3 changed files with 65 additions and 2 deletions

View File

@ -4828,8 +4828,17 @@ matrix_dendrite_container_labels_client_root_redirection_url: "{{ (('https://' i
matrix_dendrite_container_labels_federation_api_traefik_entrypoints: "{{ matrix_federation_traefik_entrypoint }}"
matrix_dendrite_container_labels_metrics_middleware_basic_auth_enabled: "{{ matrix_metrics_exposure_http_basic_auth_enabled }}"
matrix_dendrite_container_labels_metrics_middleware_basic_auth_users: "{{ matrix_metrics_exposure_http_basic_auth_users }}"
matrix_dendrite_container_extra_arguments_auto: "{{ matrix_homeserver_container_extra_arguments_auto }}"
matrix_dendrite_metrics_enabled: "{{ prometheus_enabled }}"
matrix_dendrite_metrics_proxying_enabled: "{{ matrix_dendrite_metrics_enabled and matrix_metrics_exposure_enabled }}"
matrix_dendrite_metrics_proxying_hostname: "{{ matrix_metrics_exposure_hostname }}"
matrix_dendrite_metrics_proxying_path_prefix: "{{ matrix_metrics_exposure_path_prefix }}/dendrite"
matrix_dendrite_client_api_registration_shared_secret: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'dendrite.rss', rounds=655555) | to_uuid }}"
matrix_dendrite_database_hostname: "{{ devture_postgres_connection_hostname if devture_postgres_enabled else '' }}"

View File

@ -124,6 +124,17 @@ matrix_dendrite_container_labels_federation_api_traefik_entrypoints: ''
matrix_dendrite_container_labels_federation_api_traefik_tls: "{{ matrix_dendrite_container_labels_federation_api_traefik_entrypoints != 'web' }}"
matrix_dendrite_container_labels_federation_api_traefik_tls_certResolver: "{{ matrix_dendrite_container_labels_traefik_tls_certResolver }}" # noqa var-naming
# Controls whether labels will be added that expose mautrix-facebook's metrics
matrix_dendrite_container_labels_metrics_enabled: "{{ matrix_dendrite_metrics_enabled and matrix_dendrite_metrics_proxying_enabled }}"
matrix_dendrite_container_labels_metrics_traefik_rule: "Host(`{{ matrix_dendrite_metrics_proxying_hostname }}`) && PathPrefix(`{{ matrix_dendrite_metrics_proxying_path_prefix }}`)"
matrix_dendrite_container_labels_metrics_traefik_priority: 0
matrix_dendrite_container_labels_metrics_traefik_entrypoints: "{{ matrix_dendrite_container_labels_traefik_entrypoints }}"
matrix_dendrite_container_labels_metrics_traefik_tls: "{{ matrix_dendrite_container_labels_metrics_traefik_entrypoints != 'web' }}"
matrix_dendrite_container_labels_metrics_traefik_tls_certResolver: "{{ matrix_dendrite_container_labels_traefik_tls_certResolver }}" # noqa var-naming
matrix_dendrite_container_labels_metrics_middleware_basic_auth_enabled: false
# See: https://doc.traefik.io/traefik/middlewares/http/basicauth/#users
matrix_dendrite_container_labels_metrics_middleware_basic_auth_users: ''
# matrix_dendrite_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file.
# See `../templates/labels.j2` for details.
#
@ -230,8 +241,13 @@ matrix_dendrite_app_service_config_files_final: "{{ matrix_dendrite_app_service_
# Enable exposure of metrics
matrix_dendrite_metrics_enabled: false
matrix_dendrite_metrics_username: "metrics"
matrix_dendrite_metrics_password: "metrics"
matrix_dendrite_metrics_username: ""
matrix_dendrite_metrics_password: ""
# Controls whether metrics should be exposed on a public URL.
matrix_dendrite_metrics_proxying_enabled: false
matrix_dendrite_metrics_proxying_hostname: "{{ matrix_dendrite_hostname }}"
matrix_dendrite_metrics_proxying_path_prefix: /metrics/dendrite
# Postgres database information
matrix_dendrite_database_str: "postgresql://{{ matrix_dendrite_database_user }}:{{ matrix_dendrite_database_password }}@{{ matrix_dendrite_database_hostname }}"

View File

@ -142,6 +142,44 @@ traefik.http.routers.matrix-dendrite-federation-api.tls.certResolver={{ matrix_d
/Federation-API (/_matrix)
#}
{#
Metrics
#}
{% if matrix_dendrite_container_labels_metrics_enabled %}
{% set metrics_middlewares = [] %}
{% if matrix_dendrite_container_labels_metrics_middleware_basic_auth_enabled %}
{% set metrics_middlewares = metrics_middlewares + ['matrix-dendrite-metrics-basic-auth'] %}
traefik.http.middlewares.matrix-dendrite-metrics-basic-auth.basicauth.users={{ matrix_dendrite_container_labels_metrics_middleware_basic_auth_users }}
{% endif %}
{% set metrics_middlewares = metrics_middlewares + ['matrix-dendrite-metrics-replacepath'] %}
traefik.http.middlewares.matrix-dendrite-metrics-replacepath.replacepath.path=/metrics
traefik.http.routers.matrix-dendrite-metrics.rule={{ matrix_dendrite_container_labels_metrics_traefik_rule }}
{% if metrics_middlewares | length > 0 %}
traefik.http.routers.matrix-dendrite-metrics.middlewares={{ metrics_middlewares | join(',') }}
{% endif %}
{% if matrix_dendrite_container_labels_metrics_traefik_priority | int > 0 %}
traefik.http.routers.matrix-dendrite-metrics.priority={{ matrix_dendrite_container_labels_metrics_traefik_priority }}
{% endif %}
traefik.http.routers.matrix-dendrite-metrics.service=matrix-dendrite
traefik.http.routers.matrix-dendrite-metrics.entrypoints={{ matrix_dendrite_container_labels_metrics_traefik_entrypoints }}
traefik.http.routers.matrix-dendrite-metrics.tls={{ matrix_dendrite_container_labels_metrics_traefik_tls | to_json }}
{% if matrix_dendrite_container_labels_metrics_traefik_tls %}
traefik.http.routers.matrix-dendrite-metrics.tls.certResolver={{ matrix_dendrite_container_labels_metrics_traefik_tls_certResolver }}
{% endif %}
{% endif %}
{#
/Metrics
#}
{% endif %}
{{ matrix_dendrite_container_labels_additional_labels }}