目錄
一、前言
在前面 Linux服務器監控:Grafana+InfluxDB+Telegraf監控平臺搭建這篇中講到一種服務器監控的方式。下面給大家說一下另一種服務器監控的方式,使用
node-exporter+Prometheus+Grafana
搭建的服務器監控平臺。
這裏安裝node-exporter和Prometheus都是通過Docker安裝的,關於Docker的安裝,可以參考我的這篇博客的前面一部分:Docker安裝Jenkins,它不香嗎?
二、node-exporter安裝
-
下載鏡像
docker pull prom/node-exporter
-
生成容器
docker run -d -p 9100:9100 prom/node-exporter
-
驗證是否安裝成功——訪問URL
http://服務器IP:9100/metrics
三、Prometheus安裝及配置
3.1 設置配置文件
-
創建配置文件
prometheus.yml
mkdir /home/prometheus cd /home/prometheus vim prometheus.yml
-
配置文件內容如下:其中
IP地址
填寫要監控的服務器的IP地址
,也就是前面安裝node-exporter的服務器
的IP地址global: scrape_interval:60s evaluation_interval: 60s scrape_configs: - job_name: prometheus static_configs: - targets: ['localhost:9090'] labels: instance: prometheus - job_name: linux static_configs: - targets: ['IP地址:9100'] labels: instance: localhost
3.2 Docker安裝Prometheus
- 下載鏡像
docker pull prom/prometheus
- 生成容器
docker run -d -p 9090:9090 -v /home/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
- 驗證是否安裝成功
(1)訪問URL:http://IP地址:9090/graph
(2)訪問targets:http://IP地址:9090/targets
四、Grafana安裝及配置
4.1 Grafana安裝
關於Grafana安裝請參考我前面的博客 Jmeter+Grafana+Influxdb可視化性能監控平臺搭建:讓壓測實時的“酷炫”起來!的
三、Grafana安裝及配置
。
4.2 Grafana配置Prometheus
- 添加數據源,並選擇Prometheus
- 配置Prometheus相關數據
4.3 下載模板並創建儀表盤
-
下載ID爲
11074
的模板文件,下載鏈接爲:https://grafana.com/grafana/dashboards/11074
-
導入模板:點擊+號->Import->upload .json file,選擇下載好的模板文件。
-
最後效果