feat(monitoring): deploy Prometheus + Grafana stack via Docker
- prometheus.yml: scrapes node, postgres, redis, nexus-pos, nexus-quart - docker-compose.monitoring.yml: Prometheus, Grafana, node-exporter, postgres-exporter, redis-exporter - Grafana auto-provisions Prometheus datasource - Access: Grafana :3001 (admin/nexus2026), Prometheus :9090
This commit is contained in:
60
docker/docker-compose.monitoring.yml
Normal file
60
docker/docker-compose.monitoring.yml
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
prometheus:
|
||||||
|
image: prom/prometheus:v2.51.0
|
||||||
|
container_name: nexus-prometheus
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "9090:9090"
|
||||||
|
volumes:
|
||||||
|
- ./prometheus:/etc/prometheus
|
||||||
|
- prometheus-data:/prometheus
|
||||||
|
command:
|
||||||
|
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||||
|
- '--storage.tsdb.path=/prometheus'
|
||||||
|
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
|
||||||
|
- '--web.console.templates=/usr/share/prometheus/consoles'
|
||||||
|
- '--web.enable-lifecycle'
|
||||||
|
|
||||||
|
grafana:
|
||||||
|
image: grafana/grafana:10.4.1
|
||||||
|
container_name: nexus-grafana
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "3001:3000"
|
||||||
|
volumes:
|
||||||
|
- grafana-data:/var/lib/grafana
|
||||||
|
- ./grafana/provisioning:/etc/grafana/provisioning
|
||||||
|
environment:
|
||||||
|
- GF_SECURITY_ADMIN_USER=admin
|
||||||
|
- GF_SECURITY_ADMIN_PASSWORD=nexus2026
|
||||||
|
- GF_USERS_ALLOW_SIGN_UP=false
|
||||||
|
|
||||||
|
node-exporter:
|
||||||
|
image: prom/node-exporter:v1.7.0
|
||||||
|
container_name: nexus-node-exporter
|
||||||
|
restart: unless-stopped
|
||||||
|
network_mode: host
|
||||||
|
|
||||||
|
postgres-exporter:
|
||||||
|
image: prometheuscommunity/postgres-exporter:v0.15.0
|
||||||
|
container_name: nexus-postgres-exporter
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
DATA_SOURCE_NAME: "postgresql://postgres@172.17.0.1:5432/nexus_autoparts?sslmode=disable"
|
||||||
|
ports:
|
||||||
|
- "9187:9187"
|
||||||
|
|
||||||
|
redis-exporter:
|
||||||
|
image: oliver006/redis_exporter:v1.58.0
|
||||||
|
container_name: nexus-redis-exporter
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
REDIS_ADDR: "redis://172.17.0.1:6379"
|
||||||
|
ports:
|
||||||
|
- "9121:9121"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
prometheus-data:
|
||||||
|
grafana-data:
|
||||||
9
docker/grafana/provisioning/datasources/prometheus.yml
Normal file
9
docker/grafana/provisioning/datasources/prometheus.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
|
||||||
|
datasources:
|
||||||
|
- name: Prometheus
|
||||||
|
type: prometheus
|
||||||
|
access: proxy
|
||||||
|
url: http://prometheus:9090
|
||||||
|
isDefault: true
|
||||||
|
editable: false
|
||||||
30
docker/prometheus/prometheus.yml
Normal file
30
docker/prometheus/prometheus.yml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
global:
|
||||||
|
scrape_interval: 15s
|
||||||
|
evaluation_interval: 15s
|
||||||
|
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: 'prometheus'
|
||||||
|
static_configs:
|
||||||
|
- targets: ['localhost:9090']
|
||||||
|
|
||||||
|
- job_name: 'node'
|
||||||
|
static_configs:
|
||||||
|
- targets: ['node-exporter:9100']
|
||||||
|
|
||||||
|
- job_name: 'postgres'
|
||||||
|
static_configs:
|
||||||
|
- targets: ['postgres-exporter:9187']
|
||||||
|
|
||||||
|
- job_name: 'redis'
|
||||||
|
static_configs:
|
||||||
|
- targets: ['redis-exporter:9121']
|
||||||
|
|
||||||
|
- job_name: 'nexus-pos'
|
||||||
|
static_configs:
|
||||||
|
- targets: ['host.docker.internal:5001']
|
||||||
|
metrics_path: /metrics
|
||||||
|
|
||||||
|
- job_name: 'nexus-quart'
|
||||||
|
static_configs:
|
||||||
|
- targets: ['host.docker.internal:5002']
|
||||||
|
metrics_path: /metrics
|
||||||
Reference in New Issue
Block a user