iac/ansible/roles/monitoring/tasks/main.yaml
Sergei Poljanski 27d4b73eb0
Some checks failed
deploy / ansible (push) Has been cancelled
monitoring: keep Loki chunks in S3, 90 days of logs and metrics
ops has 12 GB free on a 38 GB disk and the Traefik access log alone
is ~600 MB, so logs can't grow there. From 2026-11-14 Loki writes
chunks and index to Hetzner Object Storage (asxpio-loki-main, hel1)
with the existing project key, passed through loki.env and
-config.expand-env. Today's filesystem period ages out by retention.

Log retention goes from 14 to 90 days. Prometheus metrics are small
(~20 MB so far) and stay local, now for 90 days instead of 30.

Assisted-by: Claude:opus-5-5
2026-11-13 07:04:00 +04:00

38 lines
1.5 KiB
YAML

---
# Prometheus, Loki, Grafana, blackbox_exporter and postgres_exporter on
# asxpio-ops. Grafana: https://gf.asxp.io, WireGuard only.
- name: Create the provisioning directories
ansible.builtin.file:
path: "{{ monitoring_base_path }}/{{ item }}"
state: directory
mode: "0755"
loop:
- grafana/provisioning/datasources
- grafana/provisioning/dashboards
- grafana/provisioning/alerting
- grafana/dashboards
- name: Deploy the dashboards
ansible.builtin.copy:
src: dashboards/
dest: "{{ monitoring_base_path }}/grafana/dashboards/"
mode: "0644"
- name: Deploy the monitoring stack
ansible.builtin.include_role:
name: docker_service
vars:
service_name: monitoring
service_base_path: "{{ monitoring_base_path }}"
service_templates:
- { src: docker-compose.yml.j2, dest: docker-compose.yml }
- { src: prometheus.yml.j2, dest: prometheus.yml }
- { src: blackbox.yml.j2, dest: blackbox.yml }
- { src: loki.yml.j2, dest: loki.yml }
- { src: grafana.env.j2, dest: grafana.env, mode: "0600" }
- { src: loki.env.j2, dest: loki.env, mode: "0600" }
- { src: datasources.yaml.j2, dest: grafana/provisioning/datasources/datasources.yaml }
- { src: dashboards.yaml.j2, dest: grafana/provisioning/dashboards/dashboards.yaml }
- { src: alerting.yaml.j2, dest: grafana/provisioning/alerting/alerting.yaml }
- { src: alert-rules.yaml.j2, dest: grafana/provisioning/alerting/rules.yaml }
health_check_url: "http://{{ asxpio_ops_vpc_ip }}:{{ monitoring_loki_port }}/ready"