普羅米修斯
一 准備安裝包
1 mysqld_exporter 數據庫采集插件
2 node_exporter 客戶端采集插件
3 prometheus 監控主進程
4 grafana-dashboards 前端json文件
5 grafana 前端主進程
6 alertmanager 報警模塊
二 啟動方式
1 service grafana-server start
2 nohup ./node_exporter & 端口9100
3 mysqld_exporter --config.my-cnf=/usr/local/mysqld_exporter/my.cnf
配置文件
[client]
host=1.1.1.1
port=port
user=god
password=god
端口9104
4 nohup prometheus --storage.tsdb.retention=30d &
配置文件編寫
global:
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['prometheus:9090'] ->node
- job_name: 'server'
static_configs:
- targets: ['prometheus:9104']-> mysql
配置文件檢測
protool check config prometheus.yml
常用選項
--config.file="/usr/local/prometheus/prometheus.yml" #指定配置文件路徑
--web.listen-address="0.0.0.0:9090" #指定服務端口
--storage.tsdb.path="/data/prometheus" #指定數據存儲路徑
--storage.tsdb.retention.time=15d #數據保留時間
--collector.systemd #開啟服務狀態監控,開啟后在WEB上可以看到多出相關監控項
--collector.systemd.unit-whitelist=(sshd|nginx).service #具體要監控的服務名
--web.enable-lifecycle #開啟熱加載配置
端口9090
三訪問
http://prometheus:9090/graph
測試值
STATUS->TARGET
http://prometheus:9100/metrics->mysql測試值獲取
http://prometheus:9104/metrics->linux測試值獲取
確保所有狀態值都為up,獲取到值
STATUS->DESVOERY
查看所有配置的任務
四 grafana配置
0 訪問地址
http://prometheus:3000 ->賬號密碼都是admin
1 建立數據源
name 必須為 Prometheus
其他默認即可進行保存
2 導入grafana-dashboards需要的json
3 安裝必須插件(常用)
grafana-cli plugins install grafana-kubernetes-app
grafana-cli plugins install natel-plotly-panel
grafana-cli plugins install grafana-clock-panel
grafana-cli plugins install grafana-piechart-panel
grafana-cli plugins install percona-percona-app
grafana-cli plugins install digrich-bubblechart-panel
grafana-cli plugins install digiapulssi-breadcrumb-panel
4 觀察圖表是否有數據