prometheus和grafana、node_exporter监控服务资源
生活随笔
收集整理的這篇文章主要介紹了
prometheus和grafana、node_exporter监控服务资源
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.prometheus
說明:Prometheus是一個開源的系統監控和警報工具包
1.1.輸入命令下載Prometheus安裝包:
wget https://github.com/prometheus/prometheus/releases/download/v2.18.1/prometheus-2.18.1.linux-amd64.tar.gz1.2.輸入命令解壓:
tar -zxvf prometheus-2.18.1.linux-amd64.tar.gz -C /soft/service1.3.重命名:
mv prometheus-2.18.1.linux-amd64 prometheus1.4.進入prometheus 下輸入命令:
vim 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 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'# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ['192.168.1.128:9090'] #我們自己添加- job_name: 'Metrics'static_configs:- targets: [192.168.1.128:9100]?注意:一下配置的ip地址是安裝node_exporter的服務器ip地址+9100端口
啟動命令:
nohup ./prometheus >/dev/null 2>log &2.node_exporter
2.1.下載 Node Exporter 安裝包:
wget https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz2.2.解壓
tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz也可以解壓到指定文件:
tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz -C ?文件名2.3.重命名:
mv node_exporter-0.18.1.linux-amd64 node_exporter2.4.輸入命令:
cd ?node_exporter2.5.輸入命令啟動:
./node_exporter也可以使用這種方式啟動
nohup ./node_exporter >/dev/null 2>log &2.6. 關掉該服務的兩種方式
第一種方式:
ps aux|grep node_exporter?然后使用
kill -9 1565第二種方式:
pkill node_exporter2.7.驗證是否安裝成功
瀏覽器輸入:http://IP:9100/(IP 是它安裝在的服務器的IP)
3.Grafana
3.1.輸入命令下載并安裝:
wget?https://s3-us-west-2.amazonaws.com/grafana-releases/release/grafana-5.3.2-1.x86_64.rpm安裝:
sudo yum install?grafana-5.3.2-1.x86_64.rpm3.2.安裝后輸入命令啟動服務器:
service grafana-server start3.3.瀏覽器輸入服務器IP+端口(默認:3000) 訪問
3.4.解決端口沖突
node服務的默認端口也是3000,所以服務器上如果是安裝了node的話,就需要改grafana的默認端口3000。可以改為3001
默認用戶名和密碼為admin、admin
微信掃一掃:關注我個人訂閱號“猿小飛”,更多精彩文章在這里及時發布:
?
總結
以上是生活随笔為你收集整理的prometheus和grafana、node_exporter监控服务资源的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: centos7 通过脚本查询每个应用使用
- 下一篇: 小团队的自动化运维实践经验