Grafana Prometheus 服务安装部署(Linux服务器监控)
文章目錄
- 一、概述
- 二、安裝Prometheus
- 1.安裝node_exporter
- 2.安裝Prometheus
 
- 三、安裝Grafana展示監(jiān)控
- 監(jiān)控進(jìn)程
一、概述
Prometheus 介紹
Prometheus是一套開(kāi)源的監(jiān)控&報(bào)警&時(shí)間序列數(shù)據(jù)庫(kù)的組合,起始是由SoundCloud公司開(kāi)發(fā)的。隨著發(fā)展,越來(lái)越多公司和組織接受采用Prometheus,社區(qū)也十分活躍,他們便將它獨(dú)立成開(kāi)源項(xiàng)目,并且有公司來(lái)運(yùn)作。google SRE的書(shū)內(nèi)也曾提到跟他們BorgMon監(jiān)控系統(tǒng)相似的實(shí)現(xiàn)是Prometheus。現(xiàn)在最常見(jiàn)的Kubernetes容器管理系統(tǒng)中,通常會(huì)搭配Prometheus進(jìn)行監(jiān)控。
Prometheus 的優(yōu)點(diǎn)
Prometheus 的特性
Grafana介紹
Grafana是一個(gè)跨平臺(tái)的開(kāi)源的度量分析和可視化工具,可以通過(guò)將采集的數(shù)據(jù)查詢?nèi)缓罂梢暬恼故?#xff0c;并及時(shí)通知。它主要有以下幾個(gè)特點(diǎn):
展示方式:快速靈活的客戶端圖表,面板插件有許多不同方式的可視化指標(biāo)和日志,官方庫(kù)中具有豐富的儀表盤(pán)插件,比如熱圖、折線圖、圖表等多種展示方式;
數(shù)據(jù)源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch和KairosDB等;
通知提醒:4.0之后的添加了報(bào)警功能,可以以可視方式定義最重要指標(biāo)的警報(bào)規(guī)則,Grafana將不斷計(jì)算并發(fā)送通知,在數(shù)據(jù)達(dá)到閾值時(shí)通過(guò)Slack、PagerDuty等獲得通知;
混合展示:在同一圖表中混合使用不同的數(shù)據(jù)源,可以基于每個(gè)查詢指定數(shù)據(jù)源,甚至自定義數(shù)據(jù)源;
二、安裝Prometheus
1.安裝node_exporter
源碼地址:https://github.com/prometheus/node_exporter
在下載安裝Prometheus之前我們先安裝node_exporter插件,用于提供服務(wù)器監(jiān)控的指標(biāo)(比如:CPU、內(nèi)存、磁盤(pán)、磁盤(pán)讀寫(xiě)速率等指標(biāo)),是一個(gè)非常常用的Prometheus Client插件。
下載
wget -c https://github.com/prometheus/node_exporter/releases/download/v0.18.1/node_exporter-0.18.1.linux-amd64.tar.gz解壓
tar -zxvf node_exporter-0.18.1.linux-amd64.tar.gz后臺(tái)運(yùn)行
nohup node_exporter-0.18.1.linux-amd64/node_exporter > node_exporter-0.18.1.linux-amd64/node_exporter.stdout 2>&1 &2.安裝Prometheus
下載地址:https://prometheus.io/download/
下載版本號(hào)為2.32.1,也可以根據(jù)自己需要下載其他版本
wget -c https://github.com/prometheus/prometheus/releases/download/v2.32.1/prometheus-2.32.1.linux-amd64.tar.gz解壓
tar -zxvf prometheus-2.32.1.linux-amd64.tar.gz配置
 在prometheus.yml配置文件中追加node_exporter的job,監(jiān)控本機(jī)服務(wù)器
在prometheus.yml新增
- job_name: "node_exporter"static_configs:- targets: ["192.168.60.15:9100"]注:如果需要監(jiān)控多臺(tái)服務(wù)器指標(biāo),則只需要在其他服務(wù)器上安裝node_exporter即可,不需要安裝prometheus。參考配置如下:
- job_name: 'node_exporter'static_configs:- '192.168.20.165:9100'- '192.168.20.166:9100'- '192.168.20.167:9100'啟動(dòng)服務(wù)
nohup ./prometheus > prometheus.log &訪問(wèn)prometheus
http://192.168.60.15:9090/graph出現(xiàn)如下頁(yè)面說(shuō)明prometheus啟動(dòng)成功
 
三、安裝Grafana展示監(jiān)控
下載地址: https://grafana.com/grafana/download
下載版本:8.3.4
wget https://dl.grafana.com/enterprise/release/grafana-enterprise-8.3.4-1.x86_64.rpm安裝
sudo yum install grafana-enterprise-8.3.4-1.x86_64.rpm安裝目錄在/usr/share/grafana
 下載餅圖插件
注:安裝在/var/lib/grafana/plugins目錄下
啟動(dòng)Grafana
systemctl start grafana-server systemctl enable grafana-server訪問(wèn)Grafana
 http://192.168.60.15:3000/login,默認(rèn)賬號(hào)密碼admin/admin
 
 添加數(shù)據(jù)源
 
 
 
保存
 
 保存成功后再配置頁(yè)面可以看到我們配置的數(shù)據(jù)源
 
 導(dǎo)入node_exporter對(duì)應(yīng)的儀表盤(pán)
 
 
 導(dǎo)入成功后查看我們服務(wù)器監(jiān)控
 
 注:關(guān)于Granafa儀表盤(pán)ID可參考:
https://grafana.com/grafana/dashboards
監(jiān)控進(jìn)程
https://datamining.blog.csdn.net/article/details/122680198
總結(jié)
以上是生活随笔為你收集整理的Grafana Prometheus 服务安装部署(Linux服务器监控)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
 
                            
                        - 上一篇: Hue添加RDBMS(关系型数据库)
- 下一篇: 操作系统内核
