grafana+prometheus+node_exporter+linux
阿新 • • 發佈:2020-11-18
使用Grafana和Prometheus對Linux伺服器效能進行監控,主要通過node_exporter進行監控,指標如 CPU、記憶體、磁碟等。Prometheus通過HTTP協議從遠端的機器收集資料並存儲Prometheus本地時序資料庫。
一.監測伺服器安裝node_exporter
linux下載: wgethttps://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz
解壓:
tar xzvf node_exporter-0.18.1.linux-amd64.tar.gz
cd node_exporter-0.18.1.linux-amd64
啟動:./node_exporter
二.本地安裝prometheus,修改監測配置
1.下載並解壓:https://prometheus.io/download/
2.解壓後開啟,prometheus.yml
# my global config global: scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. # scrape_timeout is set to the globaldefault (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' # metrics_path defaults to '/metrics' # scheme defaults to 'http'. static_configs: - targets: ['localhost:9090']
在末尾加上監測的ip和埠 - job_name: 'linux-exporter' metrics_path: /metrics static_configs: - targets: ['xxx.xxx.xxx.xxx:9100']
3.監測是否監聽成功
啟動prometheus.exe,本地訪問:localhost:9090
介面展示監聽的伺服器即表示成功~~~~
三.安裝
grafana
1.下載:https://grafana.com/grafana/download
2.啟動:本地訪問localhost:3000
預設admin/admin登入,登入進去會讓你修改使用者名稱和密碼,修改即可
3.選擇Prometheus資料來源
4.進入grafana官網https://grafana.com/,從選單欄Grafana中選擇Dashboards,進入dashboards模板頁面,複製ID,這裡用的是8919,在grafana上ipmort 監聽模組: