--- # GNMON-001 v2.0: host monitoring deployment. # M1 (workstation): metrics path (collector + node_exporter + VictoriaMetrics). # M2 (workstation): log path (Loki + Alloy). Dashboard (M3) follows. - name: GNMON metrics and log paths hosts: all roles: - role: gnmon_accounts tags: [accounts, never] - role: gnmon_firewall tags: [firewall] - role: gnmon_collector tags: [collector] - role: gnmon_victoria_metrics tags: [metrics] - role: gnmon_loki tags: [logs] - role: gnmon_alloy tags: [logs] - role: gnmon_alertmanager tags: [alerting] - role: gnmon_vmalert tags: [alerting] - role: gnmon_dashboard tags: [dashboard] post_tasks: - name: Verify the GPU metrics are ingested ansible.builtin.uri: url: "http://127.0.0.1:{{ gnmon_victoria_metrics_port }}/api/v1/query?query=gn_gpu_edge_temp_celsius" status_code: 200 register: gnmon_query_result retries: 15 delay: 4 until: >- gnmon_query_result.json is defined and gnmon_query_result.json.data.result | length > 0 tags: [metrics] - name: Show the ingested GPU temperature sample ansible.builtin.debug: msg: "gn_gpu_edge_temp_celsius = {{ gnmon_query_result.json.data.result[0].value[1] }} °C" tags: [metrics] - name: Seed the development log source with a fresh line ansible.builtin.shell: | set -e dev_log="{{ lookup('ansible.builtin.env', 'HOME') }}/.local/state/gnmon/dev-test.log" mkdir -p "$(dirname "$dev_log")" echo "gnmon-m2-verification $(date -u +%%Y-%%m-%%dT%%H:%%M:%%SZ)" >> "$dev_log" args: executable: /bin/bash changed_when: false when: gnmon_alloy_file_targets | length > 0 tags: [logs] - name: Seed the journal with a verification line # Journal-based rebuild of the log-path verify: in the server (system) # scope Alloy has no file targets, only the journal. Both scopes label # the message via SYSLOG_IDENTIFIER (JSON pipeline). ansible.builtin.command: argv: - /usr/bin/logger - -t - gnmon-verify - "gnmon-m2-verification {{ ansible_date_time['iso8601'] }}" changed_when: false tags: [logs] - name: Verify the log line arrives in Loki ansible.builtin.uri: url: >- http://127.0.0.1:{{ gnmon_loki_port }}/loki/api/v1/query_range?query={syslog_identifier="gnmon-verify"}&limit=5&start={{ (now_epoch | int - 300) * 1000000000 }}&end={{ (now_epoch | int + 60) * 1000000000 }} status_code: 200 vars: now_epoch: "{{ ansible_facts['date_time']['epoch'] }}" register: gnmon_loki_query retries: 10 delay: 3 until: >- gnmon_loki_query.json is defined and gnmon_loki_query.json.data.result | length > 0 tags: [logs] - name: Show the ingested log sample ansible.builtin.debug: msg: "Loki-Ergebnisstreams: {{ gnmon_loki_query.json.data.result | length }}" tags: [logs] - name: Wait until vmalert has evaluated its first cycle ansible.builtin.uri: url: "http://{{ gnmon_vmalert_http_listen }}/-/healthy" status_code: 200 register: gnmon_vmalert_health retries: 12 delay: 5 until: gnmon_vmalert_health.status == 200 tags: [alerting] - name: Verify the self-test alert reaches Alertmanager (workstation) ansible.builtin.uri: url: "http://{{ gnmon_alertmanager_http_listen }}/api/v2/alerts" status_code: 200 register: gnmon_am_alerts retries: 15 delay: 8 until: >- gnmon_am_alerts.json is defined and gnmon_am_alerts.json | selectattr('labels.alertname', 'defined') | selectattr('labels.alertname', 'equalto', 'GnmonSelfTest') | list | length > 0 when: gnmon_vmalert_selftest_rule | bool tags: [alerting] - name: Verify Alertmanager answers (server, no self-test rule) ansible.builtin.uri: url: "http://{{ gnmon_alertmanager_http_listen }}/api/v2/alerts" status_code: 200 when: not (gnmon_vmalert_selftest_rule | bool) tags: [alerting] - name: Show the alerting path verdict ansible.builtin.debug: msg: >- vmalert -> Alertmanager funktioniert: {{ gnmon_am_alerts.json | selectattr('labels.alertname', 'defined') | map(attribute='labels.alertname') | list | join(', ') }} when: gnmon_vmalert_selftest_rule | bool tags: [alerting] # M6: with Auth enabled, "/" answers 302 (OIDC challenge via PAR toward # Keycloak) instead of 200; without auth it serves the Blazor shell (200). # The forwarded headers simulate the NPM ingress so the OIDC redirect # URI resolves to the external host registered in Keycloak. - name: Wait for the dashboard to answer ansible.builtin.uri: url: "http://{{ gnmon_dashboard_http_listen }}/" status_code: [200, 302] headers: X-Forwarded-Proto: https X-Forwarded-Host: mon.ghostnet.selfhost.eu register: gnmon_dashboard_ready retries: 20 delay: 3 until: gnmon_dashboard_ready.status in [200, 302] tags: [dashboard] - name: Verify the dashboard answers (200 shell or 302 OIDC challenge) ansible.builtin.uri: url: "http://{{ gnmon_dashboard_http_listen }}/" status_code: [200, 302] headers: X-Forwarded-Proto: https X-Forwarded-Host: mon.ghostnet.selfhost.eu return_content: false register: gnmon_dashboard_shell until: gnmon_dashboard_shell.status in [200, 302] retries: 3 delay: 2 tags: [dashboard] - name: Show the dashboard verdict ansible.builtin.debug: msg: "Dashboard antwortet auf http://{{ gnmon_dashboard_http_listen }}/" tags: [dashboard]