prometheus UI 和node_exporter節點圖形化Grafana

prometheus UI 和node_exporter節點圖形化Grafana

先簡單的安裝一下

  1. 進行時間的同步操作

安裝Prometheus之前必須要先安裝ntp時間同步,因為prometheus server對系統時間的準確性要求很高,必須保證本機時間實時同步。

# 用crontab進行定時的時間的同步
yum install ntpdate -y#寫一個定時器
crontab -e
* * * * * ntpdate ntp.aliyun.com 
  1. 安裝Prometheus之前必須要先安裝ntp時間同步,因為prometheus server對系統時間的準確性要求很高,必須保證本機時間實時同步。

安裝和啟動Prometheus server

  • prometheus的安裝非常簡單,無需要解壓,然后執行命令即可。
tar -xvzf prometheus-2.44.0.linux-amd64.tar.gz
mv prometheus-2.44.0.linux-amd64  /usr/local/prometheus
cd /usr/local/prometheus
  • 這里我們寫一個systemctl管理的腳本來啟動這個服務。
[root@prometheus-server data]# cat /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus: the alerting system
Documentation=http://prometheus.io/docs/
After=prometheus.service[Service]
ExecStart=/usr/local/prometheus/prometheus --web.enable-lifecycle --storage.tsdb.retention=90d --storage.tsdb.path=/usr/local/prometheus/data --config.file=/usr/local/prometheus/prometheus.yml
Restart=always
RestartSec=15s[Install]
WantedBy=multi-user.target
  • 介紹幾個參數

    • –config.file加載prometheus的配置文件
    • –web.listen-address #監聽prometheus的web地址和端口,默認是9090.
    • –storage.tsdb.path #數據持久化的保存路徑
    • –storage.tsdb.retention #數據持久化的時間
  • 就可以使用systemctl來管理prometheus 服務,操作如下

    systemctl daemon-reload 
    systemctl restart prometheus 
    systemctl enable prometheus # 開機自啟
    
  • 我們就可以檢查這個服務了

[root@prometheus-66 ~]# systemctl status prometheus

在這里插入圖片描述

打開prometheus UI界面和詳細使用

訪問你當前使用啟動服務主機和ip loaclhost:9090

在這里插入圖片描述

  • Prometheus UI是Prometheus內置的一個可視化管理界面,通過Prometheus UI,用戶能夠輕松的了解Prometheus當前的配置,監控任務運行狀態等。 通過Graph面板,用戶還能直接使用PromQL實時查詢監控數據。

  • Promtheus作為一個時間序列數據庫,其采集的數據會以文件的形似存儲在本地中,默認的存儲路徑為執行命令的當前data目錄下,會自動創建,用戶也可以通過參數–storage.tsdb.path="data/"修改本地數據存儲的路徑。

  • 在查詢up命令 1是存活,0是檢測失敗

在這里插入圖片描述

查看監控的有哪些的主機

prometheus server配置文件介紹

  • Prometheus的主配置文件prometheus.yml,其實prometheus解壓安裝之后,就默認自帶了一個基本的配置文件,簡單修改后的prometheus.yml文件內容如下:

    [root@prometheus-66 prometheus]# vim prometheus.yml # my global config
    global:scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.# scrape_timeout is set to the global default (10s).# Alertmanager configuration
    alerting:alertmanagers:- static_configs:- targets:# - alertmanager:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
    rule_files:# - "first_rules.yml"# - "second_rules.yml"# A scrape configuration containing exactly one endpoint to scrape:
    # Here it's Prometheus itself.
    scrape_configs:# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.- job_name: "prometheus"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090","10.0.0.110:9100","10.0.0.66:9100"]# The label name is added as a label `label_name=<label_value>` to any timeseries scraped from this config.labels:app: "prometheus"
    • 介紹一下如下:
    scrape_interval: 15s #每隔15秒向目標抓取一次數,默認為一分鐘
    evaluation_interval: 15s   #每隔15秒執行一次告警規則檢查,默認為一分鐘
    
    • scrape_configs指定的是prometheus要監控的目標,這里是整個prometheus的核心部分,在srape_config中每一個監控是一個job,但job的類型有很多。可以是最簡單的static_config,即靜態文件指定的每一個目標
    - job_name: prometheusstatic_configs:- targets: ['localhost:9090']
    
    • 也可以自己定義要監控主機的節點,這里指定的是一個prometheus本機的一個監控節點對應的9090端口,也可以繼續擴展需要監控的節點,例如:
    - job_name: 'aliyun'static_configs:-  targets:['server1:9100','IP:9100','nginxserver:9100','web01:9100','redis:9100','logserver:9100','redis2:9100']
    

    對于prometheus.yml語法的檢查

    prometool是prometheus自帶的檢測prometheus.yml的工具

[root@prometheus-66 prometheus]# ll
total 373876
-rw-r--r-- 1 root root  72649805 Dec 14  2021 grafana-8.3.3-1.x86_64.rpm
-rw-r--r-- 1 1001  118     11357 Jul 15 00:36 LICENSE
-rw-r--r-- 1 1001  118      3773 Jul 15 00:36 NOTICE
-rwxr-xr-x 1 1001  118 159425376 Jul 15 00:17 prometheus
-rw-r--r-- 1 1001  118      1128 Jul 18 14:09 prometheus.yml
-rwxr-xr-x 1 1001  118 150746286 Jul 15 00:17 promtool   
[root@prometheus-66 prometheus]# ./promtool check config prometheus.yml 
Checking prometheus.ymlSUCCESS: prometheus.yml is valid prometheus config file syntax

prometheus.yml 文件編輯完成后,進行校驗配置非常重要,如果有配置錯誤,也會給出錯誤提示.

prometheus監控Linux主機狀態

Exporter介紹

  • 所有可以向Prometheus提供監控樣本數據的程序都可以被稱為一個Exporter。而Exporter的一個實例稱為target,如下圖所示,Prometheus通過輪詢的方式定期從這些target中獲取樣本數據:

在這里插入圖片描述

(2)、用戶自定義的

我們除了可以直接使用社區提供的Exporter以外,還可以基于Prometheus提供的Client Library創建適合自己的Exporter程序,目前Promthues社區官方提供了對以下編程語言的支持:Python 、Go、Java/Scala、Ruby等。同時還有第三方實現的如:Bash、C++、Lua、Node.js、PHP、Rust等。

官方推薦的Exporter列表:https://prometheus.io/docs/instrumenting/exporters/

node_exporter介紹

  • Node exporte主要用于采集被監控主機上的cpu負載,內存的使用情況,網絡等數據,并上報數據給Prometheus server。Node_exporter 其實是一個以http_server方式運行在后臺,并且持續不斷采集 Linux系統中各種操作系統本身相關的監控參數的程序,其采集量是很快很全的,默認的采集項目就遠超過了我們的實際需求。

  • 這里我們從官網下載node_exporter

  • Prometheus官網https://prometheus.io/download/ 下載node_exporter

在這里插入圖片描述

[root@localhost ~]# tar zxvf node_exporter-1.5.0.linux-amd64.tar.gz
[root@localhost ~]# mv node_exporter-1.5.0.linux-amd64  /usr/local/node_exporter
[root@localhost ~]# cd  /usr/local/node_exporter

這里我們也編寫systemctl的腳本啟動這個服務

[root@prometheus-server data]# cat /usr/lib/systemd/system/prometheus.service
[Unit]
Description=Prometheus: the alerting system
Documentation=http://prometheus.io/docs/
After=prometheus.service[Service]
ExecStart=/usr/local/node_exporter/node_exporter 
Restart=always
RestartSec=15s[Install]
WantedBy=multi-user.target
  • 啟動這個服務并且檢測端口

在這里插入圖片描述

獲取對應的監控數據

http://localhost:9100

在這里插入圖片描述

在這里插入圖片描述

通過這個頁面可以看到Prometheus的抓取到的數據

在這里插入圖片描述

這個node節點的數據

在這里插入圖片描述

在這里插入圖片描述

這個是我們在prometheus.yml上定義的標簽,這個是可以修改的我們也可以修改為aliyun

在這個組下的都加上了這個組名字的標簽。

我們對于prometheus.yml進行修改

在這里插入圖片描述

我們修改的配置文件

scrape_configs:- job_name: "prometheus"# metrics_path defaults to '/metrics'# scheme defaults to 'http'.static_configs:- targets: ["localhost:9090"]- job_name: "aliyun.com"static_configs:- targets: ["loaclhost:9100","10.0.0.110:9100"]

我們學習查詢的語句

  1. 我們只要關于aliyun組的信息

在這里插入圖片描述

這里我們就差不多因該學會了prometheus配置文件的修改和部署,

但是這樣的儀表盤并不是很好的查看我們就需要使用圖形化工具來表示

Gragana對prometheus實現監控可視化

  • Grafana是一個開源的指標監測和可視化工具。官方網站為:https://grafana.com/, 常用于展示基礎設施的時序數據和應用程序運行分析。Grafana的dashboard展示非常炫酷,絕對是運維提升可視化監控的一大利器。

  • 數據源(datasource )

    數據的存儲源,它定義了將用什么方式來查詢數據展示在grafana上面,不同的datasource擁有不同的查詢語法,grafana支持多種數據源,官方支持以下數據源:Graphite,InfluxDB,OpenTSDB,Prometheus,Elasticsearch,CloudWatch。

    每個數據源的查詢語言和能力各不同,我們可以將來自多個數據源的數據組合到一個儀表盤中,但是每個面板都綁定到屬于特定組織的特定數據源。

  • 儀表盤(Dashboard )

    通過數據源定義好可視化的數據來源之后,對于用戶而言最重要的事情就是實現數據的可視化。在Grafana中,我們通過Dashboard來組織和管理我們的數據可視化圖表。

在這里插入圖片描述

(2)、Grafana的安裝與配置

Grafana的安裝非常簡單,官方就有軟件倉庫可以直接使用,也可以通過docker鏡像等方式直接本地啟動。還可以直接下載rpm包、二進制包進行安裝。

大家可以從 https://grafana.com/get 下載Grafana安裝包,然后根據需要的系統平臺及性能下載即可,官方給出了非常詳細的安裝方法,例如,要通過rpm包安裝在Redhat & Centos平臺,可直接執行如下命令:

[root@localhost ~]# wget https://dl.grafana.com/oss/release/grafana-8.3.3-1.x86_64.rpm
[root@localhost ~]#  yum localinstall grafana-8.3.3-1.x86_64.rpm

安裝完畢后,啟動grafana,訪問 http://your-host:3000 就可以看到登錄界面了。默認的用戶名和密碼都是admin。

本文是在centos7.x版本下進行的安裝,安裝方法與上面相同,安裝完畢后,設置一些服務自啟動即可,操作如下:

[root@localhost ~]# systemctl enable grafana-server #開啟自啟動
[root@localhost ~]# systemctl start grafana-server #啟動服務
[root@localhost ~]# systemctl status grafana-server #查看服務是否正常啟動

Grafana的配置文件位于/etc/grafana/grafana.ini,一般情況下無需修改配置文件。這樣,安裝就完成了。非常簡單。

配置promethes的信息

(4)、配置prometheus數據源

Grafana已經默認自帶了Prometheus數據源,所以無需安裝插件,直接使用即可。這里將添加Prometheus作為數據源,如下圖所示,指定數據源類型為Prometheus并且設置Prometheus的訪問地址即可:

在這里插入圖片描述

配置展示模板

在這里插入圖片描述

查看展示頁面

在這里插入圖片描述

可以看到這個儀表盤不是十分的好用我們要做一個模板

獲取docker可視化Dashboard

Grafana社區用戶分享了大量的Dashboard,可以通過訪問 https://grafana.com/dashboards 網站,找到大量可直接使用的Dashboard。推薦幾個非常不錯的Dashboard,可直接導入Grafana使用。

在這里插入圖片描述

在這里插入圖片描述

  • 從這里獲取模板的id號

在這里插入圖片描述

在這里插入圖片描述

到這里我們就對了prometheus和grafana進行了一個全面的了解后面我們將更好的學習監控服務如mysql,redis,nginx 以及后面的docker容器

看到這里可以給我點一個贊!

完結撒花🌸🌸🌸🌸🌸🌸🌸😊😊

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/89791.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/89791.shtml
英文地址,請注明出處:http://en.pswp.cn/web/89791.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

RabbitMQ—TTL、死信隊列、延遲隊列

上篇文章&#xff1a; RabbitMQ—消息可靠性保證https://blog.csdn.net/sniper_fandc/article/details/149311576?fromshareblogdetail&sharetypeblogdetail&sharerId149311576&sharereferPC&sharesourcesniper_fandc&sharefromfrom_link 目錄 1 TTL …

LVS 集群技術詳解與實戰部署

目錄 引言 一、實驗環境準備 二、理論基礎&#xff1a;集群與 LVS 核心原理 2.1 集群與分布式 2.2 LVS 核心原理 LVS 的 4 種工作模式 LVS 調度算法 三、LVS 部署工具&#xff1a;ipvsadm 命令詳解 四、實戰案例&#xff1a;LVS 部署詳解 案例 1&#xff1a;NAT 模式…

前端vue3獲取excel二進制流在頁面展示

excel二進制流在頁面展示安裝xlsx在頁面中定義一個div來展示html數據定義二進制流請求接口拿到數據并展示安裝xlsx npm install xlsx import * as XLSX from xlsx;在頁面中定義一個div來展示html數據 <div class"file-input" id"file-input" v-html&qu…

android 信息驗證動畫效果

layout_check_pro <?xml version"1.0" encoding"utf-8"?> <LinearLayout xmlns:android"http://schemas.android.com/apk/res/android"android:id"id/parent"android:layout_width"wrap_content"android:layout_…

【iOS】繼承鏈

文章目錄前言什么是繼承鏈OC中的根類關于NSProxy關鍵作用1.方法查找與動態綁定2. 消息轉發3. **類型判斷與多態**繼承鏈的底層實現元類的繼承鏈總結前言 在objective-c中&#xff0c;繼承鏈是類與類之間通過父類&#xff08;Superclass&#xff09;關系形成的一層層繼承結構&am…

論文閱讀:Instruct BLIP (2023.5)

文章目錄InstructBLIP&#xff1a;邁向通用視覺語言模型的指令微調研究總結一、研究背景與目標二、核心方法數據構建與劃分模型架構訓練策略三、實驗結果零樣本性能消融實驗下游任務微調定性分析可視化結果展示四、結論與貢獻InstructBLIP&#xff1a;邁向通用視覺語言模型的指…

Elasticsearch+Logstash+Filebeat+Kibana部署【7.1.1版本】

目錄 一、準備階段 二、實驗階段 1.配置kibana主機 2.配置elasticsearch主機 3.配置logstash主機 4.配置/etc/filebeat/filebeat.yml 三、驗證 1.開啟Filebeat 2.在logstash查看 3.瀏覽器訪問kibana 一、準備階段 1.準備四臺主機kibana、es、logstash、filebeat 2.在…

Vue開發前端報錯:‘vue-cli-service‘ 不是內部或外部命令解決方案

1.Bug: 最近調試一個現有的Vue前端代碼&#xff0c;發現如下錯誤&#xff1a; vue-cli-service’ 不是內部或外部命令&#xff0c;也不是可運行的程序 或批處理文件。 2.Bug原因&#xff1a; 導入的工程缺少依賴包&#xff1a;即缺少node_modules文件夾 3.解決方案&#xff1…

AI生態,釘釘再「出招」

如果說之前釘釘的AI生態加持更多的圍繞資源和商業的底層助力&#xff0c;那么如今這種加持則是向更深層次進化&#xff0c;即真正的AI模型訓練能力加持&#xff0c;為垂類大模型創業者提供全方位的助力&#xff0c;提高創業成功率和模型產品商業化確定性。作者|皮爺出品|產業家…

XSS GAME靶場

要求用戶不參與&#xff0c;觸發alert(1337) 目錄 Ma Spaghet! Jefff Ugandan Knuckles Ricardo Milos Ah Thats Hawt Ligma Mafia Ok, Boomer Exmaple 1 - Create Example 2 - Overwrite Example 3 - Overwrite2 toString Ma Spaghet! <h2 id"spaghet&qu…

Unity學習筆記(五)——3DRPG游戲(2)

添加更多的敵人 編輯EnemyController&#xff0c;解決報錯導致敵人無法注冊觀察者模式&#xff0c;從而無法執行敵人慶祝動畫 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.AI; public enum EnemyStatus { GUARD,PATROL…

2025測繪程序設計國賽實戰:一輪終章 | 單向后方交會C#實現

前言本文是小編對六道國賽試題中的最后一個試題&#xff0c;單向后方交會的一篇學習日志。本文的整體架構&#xff0c;依舊首先拿訓練數據跟大家介紹本題涉及到的數據的屬性含義&#xff0c;涉及到算法的原理、執行流程和終極目的。然后附上小編用C#來實現的程序&#xff0c;從…

基于Echarts的氣象數據可視化網站系統的設計與實現(Python版)

本系統旨在構建一個基于Echarts的氣象數據可視化系統&#xff0c;本系統能夠從中國天氣網爬取實時天氣數據&#xff0c;并進行存儲、分析和可視化展示。用戶可以通過網頁界面查看不同地區的天氣情況&#xff0c;以及歷史天氣數據的變化趨勢。 技術棧&#xff1a;Python語言、My…

HarmonyOS 啟動提速秘籍:懶加載全鏈路實戰解析

摘要 隨著移動應用功能越來越復雜、界面越來越豐富&#xff0c;應用啟動慢、內存占用高等問題也越來越普遍。特別是在 HarmonyOS NEXT 應用開發中&#xff0c;如果不加優化&#xff0c;用戶打開頁面時可能要等好幾秒&#xff0c;體驗就很差了。 懶加載&#xff08;Lazy Loading…

全新安裝Proxmox VE啟動時卡在Loading initial ramdisk

原因&#xff1a; 使用了Ventoy啟動盤裝載 Proxmox ISO 文件安裝。 要用Ventoy優盤啟動&#xff0c;選擇Advance Option里的Rescue Boot&#xff0c; 修改文件/etc/default/grub.d/installer.cfg&#xff0c;刪除rdinit/vtoy/vtoy運行 update-grub 更新grub配置&#xff0c;重啟…

【Java項目安全基石】登錄認證實戰:Session/Token/JWT用戶校驗機制深度解析

目錄 1.前言 2.正文 2.1Cookie—Session機制 2.1.1核心原理圖解&#xff1a; 2.1.2四步核心流程&#xff1a; 2.1.3存儲架構對比 2.1.4集群部署方案&#xff08;Spring Session Redis&#xff09; 2.2Token令牌 2.2.1核心原理圖解&#xff1a; 2.2.2四步核心流程&am…

融合優勢:SIP 廣播對講聯動華為會議 全場景溝通響應提速?

SIP 廣播對講與華為視頻會議融合解決方案&#xff0c;是基于 SIP 協議將廣播對講系統與華為視頻會議系統進行整合&#xff0c;實現通信資源共享與業務流程聯動&#xff0c;可提升應急響應效率與溝通協作能力。融合原理&#xff1a;SIP 是一種基于文本的應用層協議&#xff0c;具…

Milvus Dify 學習筆記

目錄 docker方式&#xff1a; 模式一&#xff1a;Milvus Lite linux docker方式&#xff1a; 下載yml文件&#xff0c; https://github.com/milvus-io/milvus/releases docker啟動&#xff1a; docker compose up -d from pymilvus import connections connections.conne…

汽車ECU控制器通信架構

我是穿拖鞋的漢子,魔都中堅持長期主義的汽車電子工程師。 老規矩,分享一段喜歡的文字,避免自己成為高知識低文化的工程師: 做到欲望極簡,了解自己的真實欲望,不受外在潮流的影響,不盲從,不跟風。把自己的精力全部用在自己。一是去掉多余,凡事找規律,基礎是誠信;二是…

【Linux】基本指令(入門篇)(上)

目錄 前言 1.目錄操作指令 1.1指令 1.2理論 1.2.1文件 1.2.2目錄與路徑 2.文件操作指令 2.1指令 2.2理論 2.2.1輸出與輸入 2.2.2一切皆文件 前言 這是Linux學習下的第一篇文章&#xff0c;后續Linux的學習也會持續更新分享。 Linux的基本指令是使用Linux操作系統的基礎…