性能監(jiān)控平臺 prometheus+grafana

常見性能監(jiān)控平臺

我們常見的性能建工平臺由以下幾個:

  • grafana + influxdb
  • grafana + graphite
  • grafana +Prometheus
  • grafana + zabbix

性能監(jiān)控平臺的組成部分

一般來說,一個監(jiān)控平臺的組成主要包含兩個部分

1、前端展示平臺

作用是在前端直觀的展示被測服務(wù)器的性能數(shù)據(jù)。
此處我們使用grafana來作為前端展示平臺

2、數(shù)據(jù)收集器

數(shù)據(jù)收集器的作用是實時收集被測服務(wù)器的各項性能數(shù)據(jù),并按要求存儲起來。
前端展示平臺配合數(shù)據(jù)收集器,就可以為我們組成一個基本的性能監(jiān)控平臺。
上面所說的influxdb、graphite、Prometheus以及zabbix,都可以作為數(shù)據(jù)收集器來存儲監(jiān)控數(shù)據(jù)。

prometheus+grafana 性能監(jiān)控平臺搭建

prometheus+grafana容易上手,監(jiān)控也非常全面,是最新最流行的服務(wù)器監(jiān)控平臺
安裝各個程序前先關(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、啟動grafana: `systemctl restart grafana-server`,grafana 默認端口: 3000
4、前端頁面訪問  http://grafana_ip:3000
      - 默認賬號admin
      - 默認密碼admin

打開頁面
image.png

2、prometheus

Prometheus是一個開源的系統(tǒng)監(jiān)控工具。根據(jù)配置的任務(wù)(job)以http/s周期性的收刮(scrape/pull)指定目標(target)上的指標(metric)。目標(target)可以以靜態(tài)方式或者自動發(fā)現(xiàn)方式指定。Prometheus將收刮(scrape)的指標(metric)保存在本地或者遠程存儲上。

2.1 安裝prometheus:
1、官網(wǎng)下載需要的版本tar.gz   https://prometheus.io/download/
2、把安裝包上傳到 監(jiān)控平臺機器(不是被測服務(wù)器)
3、解壓包: `tar -xzvf xxxx.tar.gz`
4、進入解壓后的文件夾:cd xxx
5、啟動prometheus  '/prometheus'或后臺運行'nohup ./prometheus &'
6、訪問前端頁面  http://prometheus_ip:9090

前端頁面
image.png

訪問成功,說明已經(jī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、啟動node-exporter
進入指定目錄/node_exporter-0.17.0.linux-amd64/下,執(zhí)行“./node_exporter”
默認node-exporter端口為9100
2.3 修改prometheus.yml

增加如下targets

  - job_name: 'node_exporter'
    static_configs:
    - targets: ['node_ip:9100']
image.png

如果有多個node_exporte,寫法為:targets: ['node1_ip:9100','node2_ip:9100']

重啟動Prometheus

pkill prometheus   #殺進程
nohup ./prometheus &   #重啟

注意:如果node機器和prometheus主機的時間不一致,需要同步時間

yum install -y ntpdate
ntpdate ntp1.aliyun.com
2.4 grafana + prometheus 前端展示

grafang添加數(shù)據(jù)源

image.png

image.png

image.png

name:自定義數(shù)據(jù)源名稱
url: http://prometheus_ip:9090
模板地址:https://grafana.com/grafana/dashboards/

image.png

image.png

image.png

數(shù)據(jù)源及模板添加成功,可以實時監(jiān)控服務(wù)器資源。


image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容