Grafana Prometheus 服务安装部署(Linux服务器监控)
文章目錄
- 一、概述
- 二、安裝Prometheus
- 1.安裝node_exporter
- 2.安裝Prometheus
- 三、安裝Grafana展示監控
- 監控進程
一、概述
Prometheus 介紹
Prometheus是一套開源的監控&報警&時間序列數據庫的組合,起始是由SoundCloud公司開發的。隨著發展,越來越多公司和組織接受采用Prometheus,社區也十分活躍,他們便將它獨立成開源項目,并且有公司來運作。google SRE的書內也曾提到跟他們BorgMon監控系統相似的實現是Prometheus。現在最常見的Kubernetes容器管理系統中,通常會搭配Prometheus進行監控。
Prometheus 的優點
Prometheus 的特性
Grafana介紹
Grafana是一個跨平臺的開源的度量分析和可視化工具,可以通過將采集的數據查詢然后可視化的展示,并及時通知。它主要有以下幾個特點:
展示方式:快速靈活的客戶端圖表,面板插件有許多不同方式的可視化指標和日志,官方庫中具有豐富的儀表盤插件,比如熱圖、折線圖、圖表等多種展示方式;
數據源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch和KairosDB等;
通知提醒:4.0之后的添加了報警功能,可以以可視方式定義最重要指標的警報規則,Grafana將不斷計算并發送通知,在數據達到閾值時通過Slack、PagerDuty等獲得通知;
混合展示:在同一圖表中混合使用不同的數據源,可以基于每個查詢指定數據源,甚至自定義數據源;
二、安裝Prometheus
1.安裝node_exporter
源碼地址:https://github.com/prometheus/node_exporter
在下載安裝Prometheus之前我們先安裝node_exporter插件,用于提供服務器監控的指標(比如:CPU、內存、磁盤、磁盤讀寫速率等指標),是一個非常常用的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后臺運行
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/
下載版本號為2.32.1,也可以根據自己需要下載其他版本
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,監控本機服務器
在prometheus.yml新增
- job_name: "node_exporter"static_configs:- targets: ["192.168.60.15:9100"]注:如果需要監控多臺服務器指標,則只需要在其他服務器上安裝node_exporter即可,不需要安裝prometheus。參考配置如下:
- job_name: 'node_exporter'static_configs:- '192.168.20.165:9100'- '192.168.20.166:9100'- '192.168.20.167:9100'啟動服務
nohup ./prometheus > prometheus.log &訪問prometheus
http://192.168.60.15:9090/graph出現如下頁面說明prometheus啟動成功
三、安裝Grafana展示監控
下載地址: 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目錄下
啟動Grafana
systemctl start grafana-server systemctl enable grafana-server訪問Grafana
http://192.168.60.15:3000/login,默認賬號密碼admin/admin
添加數據源
保存
保存成功后再配置頁面可以看到我們配置的數據源
導入node_exporter對應的儀表盤
導入成功后查看我們服務器監控
注:關于Granafa儀表盤ID可參考:
https://grafana.com/grafana/dashboards
監控進程
https://datamining.blog.csdn.net/article/details/122680198
總結
以上是生活随笔為你收集整理的Grafana Prometheus 服务安装部署(Linux服务器监控)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hue添加RDBMS(关系型数据库)
- 下一篇: 操作系统内核