鑑於近期正好在研究監控方面的工具,因此有了這篇搭建隨筆。鑑因而隨筆,因此有些地方沒有詳細解釋,後期會慢慢補上,這裏僅寫了如何搭建。html
1.軟件安裝規劃node
介於我的虛擬機只有2臺,linux
故安排:nginx
172.16.16.80redis
安排上 所有的exporter+prometheus+grafana瀏覽器
172.16.16.74curl
安裝單機rediside
和nginx工具
2.軟件獲取post
連接: https://pan.baidu.com/s/1u1OjTQctdhZU3M-tqnckFQ 提取碼: iy8n
裏面包含了
prometheus,負責採集exporter指標和提供查詢語句
node_exporter,監控主機性能好比內存,cpu等
redis_exporter,監控redis
black_box_exporter,提供icmp;get,post等模塊檢測頁面
grafana --可視化展現
1.主機監控和展現
2.redis監控和展現
3.監控某一個頁面,主機地址,Tcp鏈接和展現
1.tar -xvf prometheus-2.10.0.linux-amd64.tar.gz
2.vi prometheus.yml
3.
這裏要.yml文件注意格式問題。否則會報錯,因爲這是直接copy我本身的配置因此下面這個要注意格式問題
scrape_configs:
- job_name: 'node_exporter'
metrics_path: "/metrics"
# Override the global default and scrape targets from this job every 5 seconds.
scrape_interval: 5s
static_configs:
- targets: ['localhost:9100']
貼圖:
4.nohup ./prometheus &
1.tar -xvf node_exporter-0.18.1.linux-amd64.tar.gz
2.nohup ./node_exporter &
3.tail -f nohup.out
4.測試:curl http://172.16.16.80:9100/metrics
有返回就正常OK。或者瀏覽器帶端口9100訪問
5.http://172.16.16.80:9090/targets 進去查看exporter狀態
這樣就配置好了。
1.配置數據源
2.展現:
Dashboard創建一個模板
add query
選擇數據源
輸入指標:node_load5{instance="localhost:9100"} / on (instance) count(count(node_cpu_seconds_total{instance="localhost:9100"}) by (instance,cpu))by(instance) * 100
3.關於指標的問題只能本身搜索是咋用。並且指標只要訪問9100這個端口都能看獲得。後期會專門寫一下經常使用的指標和grafana的一些用法
4.關於指標的使用我的用相似html標籤理解,指標名稱+各類屬性過濾數據 node_load5{instance="localhost:9100"}