docker-compose部署Prometheus+grafana


1.docker和docker-compose請自行下載安裝

2.docker-compose.-prometheus.yml文件

 1 vim docker-compose-prometheus.yml  2 
 3 version: "3.7"
 4 services:  5   node-exporter:  6     image: prom/node-exporter:latest  7     network_mode: "host"
 8 # prots:  9 #      - "9100:9100"
10  restart: always 11  prometheus: 12     image: prom/prometheus:latest 13     network_mode: "host"
14  restart: always 15 # prots: 16 #      - "9090:9090"
17  volumes: 18       - "./prometheus.yml:/etc/prometheus/prometheus.yml"
19       - "./prometheus_data:/prometheus"
20  grafana: 21     image: grafana/grafana 22     network_mode: "host"
23 # prots: 24 #      - "3000:3000"
25  restart: always 26  volumes: 27       - "./grafana_data:/var/lib/grafana"
prometheus主機需要部署以上容器,其他被監控主機只需要部署node-exporter
3.prometheus配置文件
vim prometheus.yml # my global config global: scrape_interval: 5s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 5s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the global default (10s). # Alertmanager configuration alerting: alertmanagers: - static_configs: - targets: # - alertmanager:9093 # Load rules once and periodically evaluate them according to the global 'evaluation_interval'. rule_files: # - "first_rules.yml" # - "second_rules.yml" # A scrape configuration containing exactly one endpoint to scrape: # Here it's Prometheus itself.
scrape_configs: # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config. - job_name: 'prometheus' static_configs: - targets: ['172.16.48.51:9090'] #prometheus主機地址 - job_name: 'node' static_configs: - targets: ['172.16.48.51:9100','172.16.49.14:9100','172.16.49.43:9100']      #監控node-exporter地址

4.docker-compose啟動

./docker-compose -f docker-compose-prometheus.yml up -d         # 掛載目錄給權限,不然會啟動失敗

5.訪問主機的9090端口可以查到Prometheus監控到的數據,訪問3000端口是grafana的界面,

   賬密admin/admin

6.配置監控,點擊齒輪,選擇Data Sources

0

7.點擊Add data source

0

 

 8.填寫prometheus地址 ip+端口或者主機名+端口(需要配置hosts)

0
9.點擊save&test
0
10.點擊+號,選擇import
0
11.輸入模板號9276,點擊load
0
0
11.導入模板完成
0


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM