From 11648958cd9d560eb85a46948d3d31b1578c1c25 Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Sat, 16 Nov 2024 01:39:02 +0500 Subject: [PATCH] Set up monitoring for peertube --- roles/haproxy/files/haproxy.cfg | 3 ++- roles/monitoring/templates/prometheus.yml.j2 | 3 +++ roles/peertube/tasks/main.yml | 9 +++++++++ roles/peertube/templates/production.yaml.j2 | 4 ++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/roles/haproxy/files/haproxy.cfg b/roles/haproxy/files/haproxy.cfg index d2d6320..078efd6 100644 --- a/roles/haproxy/files/haproxy.cfg +++ b/roles/haproxy/files/haproxy.cfg @@ -180,8 +180,9 @@ backend grafana backend peertube mode http + option httpchk GET /.well-known/nodeinfo http-response set-header Onion-Location http://vcomfyooxdbibyusen75qbzaunrjykw2cxkc6txm6qykkdv4z2danpid.onion%[capture.req.uri] - server s1 peertube:9000 check + server s1 peertube:9000 check inter 15s backend authentik mode http diff --git a/roles/monitoring/templates/prometheus.yml.j2 b/roles/monitoring/templates/prometheus.yml.j2 index 978a046..8411f43 100644 --- a/roles/monitoring/templates/prometheus.yml.j2 +++ b/roles/monitoring/templates/prometheus.yml.j2 @@ -17,3 +17,6 @@ scrape_configs: - job_name: authentik static_configs: - targets: ["authentik-1:9300"] + - job_name: peertube + static_configs: + - targets: ["peertube:9091"] diff --git a/roles/peertube/tasks/main.yml b/roles/peertube/tasks/main.yml index 06afc49..9c8f59b 100644 --- a/roles/peertube/tasks/main.yml +++ b/roles/peertube/tasks/main.yml @@ -48,6 +48,7 @@ - name: peertube - name: haproxy - name: postgresql + - name: monitoring volumes: - /mnt/hdd/peertube:/data - /etc/peertube:/config @@ -57,3 +58,11 @@ tmpfs_size: "4G" recreate: "{{ cfg.changed }}" restart_policy: unless-stopped + healthcheck: + test: ["CMD", "curl", "--fail", "http://127.0.0.1:9000/.well-known/nodeinfo"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 30s + # TODO: enable after ansible update + # state: healthy diff --git a/roles/peertube/templates/production.yaml.j2 b/roles/peertube/templates/production.yaml.j2 index d4d078b..3309b65 100644 --- a/roles/peertube/templates/production.yaml.j2 +++ b/roles/peertube/templates/production.yaml.j2 @@ -198,7 +198,7 @@ log: # For more information: https://docs.joinpeertube.org/maintain/observability open_telemetry: metrics: - enabled: false + enabled: true # How often viewers send playback stats to server playback_stats_interval: '15 seconds' @@ -209,7 +209,7 @@ open_telemetry: # Create a prometheus exporter server on this port so prometheus server can scrape PeerTube metrics prometheus_exporter: - hostname: '127.0.0.1' + hostname: '0.0.0.0' port: 9091 tracing: