diff --git a/roles/alpina/collections/services/monitoring/templates/docker-compose.yml.j2 b/roles/alpina/collections/services/monitoring/templates/docker-compose.yml.j2 index b0e7b4a..7fe0f77 100644 --- a/roles/alpina/collections/services/monitoring/templates/docker-compose.yml.j2 +++ b/roles/alpina/collections/services/monitoring/templates/docker-compose.yml.j2 @@ -53,3 +53,13 @@ services: - /var/log:/var/log:ro tmpfs: - /tmp + + prometheus: + image: prom/prometheus:latest + container_name: prometheus + restart: unless-stopped + user: "{{ remote_uid }}" + volumes: + - ./prometheus_config:/etc/prometheus:ro + - {{ base_volume_path }}/monitoring/prometheus_configs:/etc/prometheus/extra:ro + - {{ base_volume_path }}/monitoring/prometheus:/prometheus diff --git a/roles/alpina/collections/services/monitoring/templates/grafana_config/provisioning/datasources/alpina.yaml.j2 b/roles/alpina/collections/services/monitoring/templates/grafana_config/provisioning/datasources/alpina.yaml.j2 index 7e6af83..fe427ad 100644 --- a/roles/alpina/collections/services/monitoring/templates/grafana_config/provisioning/datasources/alpina.yaml.j2 +++ b/roles/alpina/collections/services/monitoring/templates/grafana_config/provisioning/datasources/alpina.yaml.j2 @@ -8,3 +8,11 @@ datasources: uid: loki url: http://loki:3100 editable: false + + - name: Prometheus + type: prometheus + version: 1 + access: proxy + uid: prometheus + url: http://prometheus:9090 + editable: false diff --git a/roles/alpina/collections/services/monitoring/templates/prometheus_config/extra/.gitkeep b/roles/alpina/collections/services/monitoring/templates/prometheus_config/extra/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/roles/alpina/collections/services/monitoring/templates/prometheus_config/prometheus.yml.j2 b/roles/alpina/collections/services/monitoring/templates/prometheus_config/prometheus.yml.j2 new file mode 100644 index 0000000..5e6e512 --- /dev/null +++ b/roles/alpina/collections/services/monitoring/templates/prometheus_config/prometheus.yml.j2 @@ -0,0 +1,31 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + + external_labels: + monitor: "{{ ansible_host }}" + +scrape_configs: + - job_name: "prometheus" + static_configs: + - targets: ["localhost:9090"] + + - job_name: "node" + static_configs: + - targets: ["{{ ansible_host }}:9100"] + + - job_name: "loki" + static_configs: + - targets: ["loki:3100"] + + - job_name: "promtail" + static_configs: + - targets: ["promtail:9080"] + +rule_files: + - "/etc/prometheus/extra/rules/*.yml" + - "/etc/prometheus/extra/rules/*.json" + +scrape_config_files: + - "/etc/prometheus/extra/scrape_configs/*.yml" + - "/etc/prometheus/extra/scrape_configs/*.json" diff --git a/roles/common/tasks/main.yml b/roles/common/tasks/main.yml index 986ce7d..caeb3da 100644 --- a/roles/common/tasks/main.yml +++ b/roles/common/tasks/main.yml @@ -5,6 +5,7 @@ - docker-ce - docker-compose-plugin - firewalld + - prometheus-node-exporter state: latest - name: Upgrade Debian packages