常見性能監(jiān)控平臺(tái)
我們常見的性能建工平臺(tái)由以下幾個(gè):
- grafana + influxdb
- grafana + graphite
- grafana +Prometheus
- grafana + zabbix
性能監(jiān)控平臺(tái)的組成部分
一般來說,一個(gè)監(jiān)控平臺(tái)的組成主要包含兩個(gè)部分
1渡紫、前端展示平臺(tái)
作用是在前端直觀的展示被測服務(wù)器的性能數(shù)據(jù)。
此處我們使用grafana來作為前端展示平臺(tái)
2、數(shù)據(jù)收集器
數(shù)據(jù)收集器的作用是實(shí)時(shí)收集被測服務(wù)器的各項(xiàng)性能數(shù)據(jù),并按要求存儲(chǔ)起來止邮。
前端展示平臺(tái)配合數(shù)據(jù)收集器捌显,就可以為我們組成一個(gè)基本的性能監(jiān)控平臺(tái)。
上面所說的influxdb国瓮、graphite、Prometheus以及zabbix狞谱,都可以作為數(shù)據(jù)收集器來存儲(chǔ)監(jiān)控?cái)?shù)據(jù)乃摹。
prometheus+grafana 性能監(jiān)控平臺(tái)搭建
prometheus+grafana容易上手,監(jiān)控也非常全面跟衅,是最新最流行的服務(wù)器監(jiān)控平臺(tái)
安裝各個(gè)程序前先關(guān)掉防火墻
systemctl stop firewalld
systemctl disable firewalld
1孵睬、grafana
Grafana是開源的、炫酷的可視化監(jiān)控伶跷、分析利器掰读,無論您的數(shù)據(jù)在哪里,或者它所處的數(shù)據(jù)庫是什么類型叭莫,您都可以將它與Grafana精美地結(jié)合在一起蹈集。
安裝grafana:
1、下載grafana的rpm包 https://grafana.com/grafana/download
2雇初、安裝:yum install xxx.rpm
3拢肆、啟動(dòng)grafana: `systemctl restart grafana-server`,grafana 默認(rèn)端口: 3000
4靖诗、前端頁面訪問 http://grafana_ip:3000
- 默認(rèn)賬號(hào)admin
- 默認(rèn)密碼admin
打開頁面2郭怪、prometheus
Prometheus是一個(gè)開源的系統(tǒng)監(jiān)控工具。根據(jù)配置的任務(wù)(job)以http/s周期性的收刮(scrape/pull)指定目標(biāo)(target)上的指標(biāo)(metric)呻畸。目標(biāo)(target)可以以靜態(tài)方式或者自動(dòng)發(fā)現(xiàn)方式指定移盆。Prometheus將收刮(scrape)的指標(biāo)(metric)保存在本地或者遠(yuǎn)程存儲(chǔ)上。
2.1 安裝prometheus:
1伤为、官網(wǎng)下載需要的版本tar.gz https://prometheus.io/download/
2咒循、把安裝包上傳到 監(jiān)控平臺(tái)機(jī)器(不是被測服務(wù)器)
3据途、解壓包: `tar -xzvf xxxx.tar.gz`
4、進(jìn)入解壓后的文件夾:cd xxx
5叙甸、啟動(dòng)prometheus '/prometheus'或后臺(tái)運(yùn)行'nohup ./prometheus &'
6颖医、訪問前端頁面 http://prometheus_ip:9090
前端頁面訪問成功,說明已經(jīng)安裝啟動(dòng)成功
2.2 安裝node_exporter
監(jiān)控liunx裆蒸,需要用到node-exporter來收集被監(jiān)控的服務(wù)器的數(shù)據(jù)
1熔萧、下載
[https://github.com/prometheus/node_exporter/releases/download/v0.17.0/node_exporter-0.17.0.linux-amd64.tar.gz]
2、解壓到指定目錄
tar -xvf node_exporter-0.17.0.linux-amd64.tar.gz -C /usr/local/
3僚祷、啟動(dòng)node-exporter
進(jìn)入指定目錄/node_exporter-0.17.0.linux-amd64/下佛致,執(zhí)行“./node_exporter”
默認(rèn)node-exporter端口為9100
2.3 修改prometheus.yml
增加如下targets
- job_name: 'node_exporter'
static_configs:
- targets: ['node_ip:9100']
如果有多個(gè)node_exporte,寫法為:targets: ['node1_ip:9100','node2_ip:9100']
重啟動(dòng)Prometheus
pkill prometheus #殺進(jìn)程
nohup ./prometheus & #重啟
注意:如果node機(jī)器和prometheus主機(jī)的時(shí)間不一致,需要同步時(shí)間
yum install -y ntpdate
ntpdate ntp1.aliyun.com
2.4 grafana + prometheus 前端展示
grafang添加數(shù)據(jù)源
name:自定義數(shù)據(jù)源名稱
url: http://prometheus_ip:9090
模板地址:https://grafana.com/grafana/dashboards/
數(shù)據(jù)源及模板添加成功辙谜,可以實(shí)時(shí)監(jiān)控服務(wù)器資源俺榆。