Prometheus
ติดตั้ง prometheus และ node_exporter เพื่อใช้สำหรับการ Monitoring
ติดตั้ง
Dockerให้เรียบร้อยสร้างไฟล์
docker-compose.ymlเพื่อใช้สำหรับ Run docker
yml
networks:
xxxxx-network:
external: true
volumes:
xxxxx-data:
driver: local
services:
prometheus:
image: prom/prometheus:xx.xx.xx
container_name: prometheus
restart: always
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
- ./prometheus-data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.retention.time=5y'
ports:
- 'xxxx:xxxx'
networks:
- xxxxx-network
node_exporter:
image: prom/node-exporter:xx.xx.xx
container_name: node_exporter
restart: always
volumes:
- /proc:/host/proc:ro
- /sys:/host/sys:ro
- /:/rootfs:ro
command:
- '--path.procfs=/host/proc'
- '--path.rootfs=/rootfs'
- '--path.sysfs=/host/sys'
- '--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)'
ports:
- 'xxxx:xxxx'
networks:
- xxxxx-network- สร้างไฟล์
prometheus.ymlเพื่อใช้ตั้งค่า prometheus
yml
global:
scrape_interval: 15s
evaluation_interval: 15s
rule_files:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['xxx:yyy']
- job_name: 'node'
static_configs:
- targets: ['xxx:yyy']- ใช้คำสั่ง docker compose เพื่อ run docker compose
bash
docker compose up -dทดสอบการทำงานของ
node_exporterโดยเข้าไปที่192.xxx.xxx.xxx:portถ้าใช้งานได้จะได้หน้าจอแบบนี้
ทดสอบการทำงานของ
prometheusโดยเข้าไปที่192.xxx.xxx.xxx:portถ้าใช้งานได้จะได้หน้าจอแบบนี้
✨ สนับสนุน💰เป็นกำลังใจ ❤️