cd /home/xxxx mkdir -p prometheus chmod 777 prometheus cd prometheus mkdir -p grafana_data prometheus_data chmod 777 grafana_data prometheus_data
docker-compose.yml
version: "3.7" services: node-exporter: image: prom/node-exporter:latest container_name: "node-exporter0" ports: - "9100:9100" restart: always prometheus: image: prom/prometheus:latest container_name: "prometheus0" restart: always ports: - "9090:9090" volumes: - "./prometheus.yml:/etc/prometheus/prometheus.yml" - "./prometheus_data:/prometheus" grafana: image: grafana/grafana container_name: "grafana0" ports: - "3000:3000" restart: always volumes: - "./grafana_data:/var/lib/grafana"
promethous.yml
global: scrape_interval: 15s # 默认抓取周期 external_labels: monitor: 'codelab-monitor' scrape_configs: - job_name: 'node-exporter' #服务的名称 scrape_interval: 5s metrics_path: /metrics #获取指标的url static_configs: - targets: ['localhost:9100'] # 这个为监听指定服务服务的ip和port,需要修改为自己的ip,貌似云服务必须用公网ip
docker-compose up -d
标签:node,compose,Prometheus,grafana,prometheus,docker,data,yml
From: https://www.cnblogs.com/lovezhr/p/17606211.html