日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > windows >内容正文

windows

Grafana+Prometheus打造运维监控系统(一)-安装篇

發(fā)布時間:2024/3/26 windows 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Grafana+Prometheus打造运维监控系统(一)-安装篇 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

1. Prometheus、Grafana介紹

Prometheus是一個開源的系統(tǒng)監(jiān)控和報警系統(tǒng),Grafana 是一個開源的監(jiān)控數(shù)據(jù)分析和可視化套件,利用Grafana+Prometheus組合,打造運維日常的各種指標(biāo)監(jiān)控以及數(shù)據(jù)可視化。

2. Prometheus

2.1 下載

訪問:https://prometheus.io/download/,選擇對應(yīng)版本,下載保存到服務(wù)器中。我這里選擇的是2022-12-01發(fā)布的2.40.5版本。

2.2 安裝

解壓到/etc/路徑下,并重命名文件夾名字為prometheus

tar zxvf prometheus-2.40.5.linux-amd64.tar.gz -C /etc/ cd /etc/ mv prometheus-2.40.5.linux-amd64 prometheus

2.3 注冊為系統(tǒng)服務(wù)并設(shè)置開機(jī)自啟

vi /usr/lib/systemd/system/prometheus.service,添加如下內(nèi)容:

[Service] ExecStart=/etc/prometheus/prometheus --config.file=/etc/prometheus/prometheus.yml ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure[Install] WantedBy=multi-user.target[Unit] Description=node_exporter After=network.target systemctl daemon-reload # 重新加載使服務(wù)配置文件生效 systemctl enable prometheus # 添加開機(jī)自啟 systemctl start prometheus # 啟動Prometheus

此時Prometheus已經(jīng)啟動,默認(rèn)的訪問端口是9090

關(guān)閉防火墻systemctl stop firewalld.service,瀏覽器輸入虛擬機(jī)IP:9090,出現(xiàn)如下頁面,代表訪問正常。

3. Grafana

3.1 下載&安裝

訪問:https://grafana.com/grafana/download,選擇對應(yīng)版本,下載保存到服務(wù)器中。我這里選擇的是2022-12-02發(fā)布的9.3.1版本,選擇自己對應(yīng)的Linux發(fā)行版本,進(jìn)行安裝。

wget https://dl.grafana.com/enterprise/release/grafana-enterprise-9.3.1-1.x86_64.rpm sudo rpm -i --nodeps grafana-enterprise-9.3.1-1.x86_64.rpm


安裝完成后,執(zhí)行systemctl start grafana-server.service啟動grafana服務(wù),默認(rèn)監(jiān)聽的是3000端口,可通過修改/etc/grafana/grafana.ini配置文件進(jìn)行修改。


如果想修改端口,取消注釋用的;號,并修改3000為你想要的值
瀏覽器輸入虛擬機(jī)IP:3000,出現(xiàn)如下頁面,代表訪問正常.
初始賬號:admin
初始密碼:admin

驗證成功后,會要求你輸入新的密碼,也可以點擊skip選擇跳過,我個人為了方便,設(shè)置為123456,溫馨提示:生產(chǎn)環(huán)境請勿使用簡單密碼哦~!

4. 安裝節(jié)點采集器node_exporter

node_exporter可以采集服務(wù)器的各種指標(biāo),比如CPU、內(nèi)存、磁盤、網(wǎng)絡(luò)等,形成時序數(shù)據(jù)。

4.1 下載

訪問:https://prometheus.io/download/#node_exporter,選擇對應(yīng)版本,下載保存到服務(wù)器中

4.2 安裝

解壓到/etc/路徑下,并重命名文件夾名字為node_exporter

tar zxvf node_exporter-1.4.0.linux-amd64.tar.gz -C /etc/ cd /etc/ mv node_exporter-1.5.0.linux-amd64/ node_exporter

4.3 注冊為系統(tǒng)服務(wù)并設(shè)置開機(jī)自啟

vi /usr/lib/systemd/system/prometheus.service,添加如下內(nèi)容:

[Service] ExecStart=/etc/node_exporter/node_exporter ExecReload=/bin/kill -HUP $MAINPID KillMode=process Restart=on-failure[Install] WantedBy=multi-user.target[Unit] Description=node_exporter After=network.target systemctl daemon-reload # 重新加載使服務(wù)配置文件生效 systemctl enable node_exporter.service # 添加開機(jī)自啟 systemctl start node_exporter.service # 啟動

此時node_exporter已經(jīng)啟動,默認(rèn)的訪問端口是9100

瀏覽器輸入虛擬機(jī)IP:9090,出現(xiàn)如下頁面,代表訪問正常。

5. Grafana數(shù)據(jù)可視化展示

5.1 添加Prometheus抓取任務(wù)

vi /etc/prometheus/prometheus.yml,添加如下內(nèi)容:

- job_name: 'node_exporter'static_configs:- targets: ["localhost:9100"]

5.2 重啟Prometheus

systemctl restart prometheus

5.3 添加grafana數(shù)據(jù)源

左側(cè)導(dǎo)航欄,設(shè)置–>Datasouces–>Add data souce

選擇Prometheus

URL框輸入:http://localhost:9090,

Save & test,提示Data souce is working,說明添加數(shù)據(jù)源成功

5.4 添加儀表盤

grafana提供了各式各樣的儀表盤,除了自己手動創(chuàng)建,我們也可以使用別人已經(jīng)做好的儀表盤進(jìn)行導(dǎo)入。
左側(cè)導(dǎo)航欄,Dashboards–>Import

導(dǎo)入的方式有兩種,第一種是本地上傳json文件;第二種是從grafana導(dǎo)入,但是要指明對應(yīng)的儀表盤URL或者ID。這里我們選擇第二種方式

訪問:https://grafana.com/grafana/dashboards/,選擇Collector Types為Node exporter,點擊Node Exporter Full進(jìn)入詳情頁,得到ID為1860


輸入1860,點擊Load進(jìn)行加載
選擇數(shù)據(jù)源為Prometheus,點擊Import進(jìn)行導(dǎo)入。

這樣就得到了一個漂亮的可視化儀表盤了,是不是So Easy呀~!

總結(jié)

以上是生活随笔為你收集整理的Grafana+Prometheus打造运维监控系统(一)-安装篇的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。