Add monitoring auto-deployment

This commit is contained in:
Your Name
2026-09-19 13:13:47 +05:00
commit 86e1c44d85
16 changed files with 422 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
ports:
- "9090:9090"
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
- ./prometheus-web.yml:/etc/prometheus/prometheus-web.yml:ro
- prom_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--web.config.file=/etc/prometheus/prometheus-web.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.enable-admin-api'
restart: unless-stopped
grafana:
image: grafana/grafana:latest
container_name: grafana
ports:
- "3001:3000"
volumes:
- ./grafana_provisioning/datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml:ro
- grafana_data:/var/lib/grafana
environment:
- GF_SECURITY_ADMIN_USER="{{ grafana_admin_user }}"
- GF_SECURITY_ADMIN_PASSWORD="{{ grafana_admin_password }}"
- GF_USERS_ALLOW_SIGN_UP=false
restart: unless-stopped
depends_on:
- prometheus
volumes:
prom_data:
grafana_data:
+12
View File
@@ -0,0 +1,12 @@
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
basicAuth: true
basicAuthUser: {{ prom_admin_user }}
secureJsonData:
basicAuthPassword: {{ prom_admin_password }}
isDefault: true
+2
View File
@@ -0,0 +1,2 @@
basic_auth_users:
{{ exporter_user }}: "{{ exporter_password | password_hash('bcrypt') }}"
+24
View File
@@ -0,0 +1,24 @@
[Unit]
Description=Node Exporter
Wants=network-online.target
After=network-online.target
[Service]
User=node_exporter
Group=node_exporter
Type=simple
ExecStart=/usr/local/bin/node_exporter \
--web.config.file=/etc/node_exporter/web.yml
# Контроль падений и перезапуск
Restart=always
RestartSec=5s
# Ограничения безопасности процесса
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
+2
View File
@@ -0,0 +1,2 @@
basic_auth_users:
{{ prom_admin_user }}: "{{ prom_admin_password | password_hash('bcrypt') }}"
+23
View File
@@ -0,0 +1,23 @@
global:
scrape_interval: 15s
scrape_configs:
- job_name: "prometheus"
scrape_interval: 15s
basic_auth:
username: "{{ prom_admin_user }}"
password: "{{ prom_admin_password }}"
static_configs:
- targets: ["localhost:9090"]
- job_name: "node_exporter"
basic_auth:
username: "{{ exporter_user }}"
password: "{{ exporter_password }}"
static_configs:
{% for host in groups['servers'] %}
- targets: ["{{ hostvars[host]['ansible_host'] }}:9100"]
labels:
nodename: "{{ host }}"
{% endfor %}