欧美性猛交xxxx免费看_牛牛在线视频国产免费_天堂草原电视剧在线观看免费_国产粉嫩高清在线观看_国产欧美日本亚洲精品一5区

0
  • 聊天消息
  • 系統(tǒng)消息
  • 評(píng)論與回復(fù)
登錄后你可以
  • 下載海量資料
  • 學(xué)習(xí)在線課程
  • 觀看技術(shù)視頻
  • 寫文章/發(fā)帖/加入社區(qū)
會(huì)員中心
創(chuàng)作中心

完善資料讓更多小伙伴認(rèn)識(shí)你,還能領(lǐng)取20積分哦,立即完善>

3天內(nèi)不再提示

從零入門Prometheus:構(gòu)建企業(yè)級(jí)監(jiān)控與報(bào)警系統(tǒng)的最佳實(shí)踐指南

馬哥Linux運(yùn)維 ? 來源:馬哥Linux運(yùn)維 ? 2025-02-10 11:28 ? 次閱讀

測試環(huán)境

prometheus-2.26.0.linux-amd64.tar.gz
下載地址:https://github.com/prometheus/prometheus/releases/download/v2.26.0/prometheus-2.26.0.linux-amd64.tar.gz
prometheus-2.54.1.linux-amd64.tar.gz
下載地址:https://github.com/prometheus/prometheus/releases/download/v2.26.0/prometheus-2.26.0.linux-amd64.tar.gz
CentOS 7.9

下載并運(yùn)行Prometheus

# wget https://github.com/prometheus/prometheus/releases/download/v2.26.0/prometheus-2.26.0.linux-amd64.tar.gz
# tar xvzf prometheus-2.26.0.linux-amd64.tar.gz
# cd prometheus-2.26.0.linux-amd64
# ls
console_libraries  consoles  LICENSE  NOTICE  prometheus  prometheus.yml  promtool

開始運(yùn)行之前,先對(duì)它進(jìn)行配置。

配置Prometheus自身監(jiān)控

Prometheus通過抓取度量HTTP端點(diǎn)來從目標(biāo)收集指標(biāo)。由于Prometheus以同樣的方式暴露自己的數(shù)據(jù),它也可以搜集和監(jiān)控自己的健康狀況。
雖然只收集自身數(shù)據(jù)的Prometheus服務(wù)器不是很有用,但它是一個(gè)很好的開始示例。保存以下Prometheus基礎(chǔ)配置到一個(gè)名為prometheus.yml的文件(安裝包自動(dòng)解壓后,解壓目錄下,默認(rèn)就就有一個(gè)名為prometheus.yml的文件)

global:
  scrape_interval:     15s # 默認(rèn),每15秒采樣一次目標(biāo)

  # 與其它外部系統(tǒng)(比如federation, remote storage, Alertmanager)交互時(shí),會(huì)附加這些標(biāo)簽到時(shí)序數(shù)據(jù)或者報(bào)警
  external_labels:
    monitor: 'codelab-monitor'

# 一份采樣配置僅包含一個(gè) endpoint 來做采樣
# 下面是 Prometheus 本身的endpoint:
scrape_configs:
  # job_name 將被被當(dāng)作一個(gè)標(biāo)簽 `job=`添加到該配置的任意時(shí)序采樣.
  - job_name: 'prometheus'

    # 覆蓋全局默認(rèn)值,從該job每5秒對(duì)目標(biāo)采樣一次
    scrape_interval: 5s

    static_configs:
      # 如果需要遠(yuǎn)程訪問, localhost  也可以替換為具體IP,比如10.118.71.170
      - targets: ['localhost:9090']

有關(guān)配置選項(xiàng)的完整說明,請(qǐng)參閱配置文檔。

啟動(dòng)Prometheus

使用新創(chuàng)建的配置文件來啟動(dòng) Prometheus,切換到包含 Prometheus 二進(jìn)制文件的目錄并運(yùn)行

# 啟動(dòng) Prometheus.
# 默認(rèn)地, Prometheus 在 ./data 路徑下存儲(chǔ)其數(shù)據(jù)庫 (flag --storage.tsdb.path).
# ./prometheus --config.file=prometheus.yml

通過訪問localhost:9000來瀏覽狀態(tài)頁。等待幾秒讓他從自己的 HTTP metric endpoint 來收集數(shù)據(jù)。

還可以通過訪問到其 metrics endpoint(http://localhost:9090/metrics)來驗(yàn)證 Prometheus 是否正在提供有關(guān)其自身的 metrics

開放防火墻端口

# firewall-cmd --permanent --zone=public --add-port=9090/tcp
success
# firewall-cmd --reload
success

使用expressin browser

使用 Prometheus 內(nèi)置的expressin browser訪問localhost:9090/graph,選擇Graph導(dǎo)航菜單下的Tabletab頁 (Classic UI下為Consoletab頁)。

通過查看localhost:9090/metrics頁面內(nèi)容可知,Prometheus 導(dǎo)出了關(guān)于其自身的一個(gè)名為prometheus_target_interval_length_seconds指標(biāo)(目標(biāo)采樣之間的實(shí)際間隔)。將其作為搜索表達(dá)式,輸入到表達(dá)式搜索框中,點(diǎn)擊Execute按鈕,如下,將返回多個(gè)不同的時(shí)間序列(以及每個(gè)時(shí)間序列的最新值),所有時(shí)間序列的 metric 名稱均為prometheus_target_interval_length_seconds,但具有不同的標(biāo)簽。這些標(biāo)簽具有不同的延遲百分比和目標(biāo)組間隔(target group intervals)。

7f3e8e9c-e6df-11ef-9310-92fbcf53809c.png

如果我們只對(duì)第 99 個(gè)百分位延遲感興趣,則可以使用以下查詢來檢索該信息

prometheus_target_interval_length_seconds{quantile="0.99"}

如果需要計(jì)算返回的時(shí)間序列數(shù),可以修改查詢?nèi)缦拢?/p>

count(prometheus_target_interval_length_seconds)

更多有關(guān) expression language 的更多信息,請(qǐng)查看 expression language 文檔。

使用繪圖界面

要繪制圖形表達(dá)式,請(qǐng)使用 “Graph” 選項(xiàng)卡。

例如,輸入以下表達(dá)式以繪制在自采樣的 Prometheus 中每秒創(chuàng)建 chunk 的速率:

rate(prometheus_tsdb_head_chunks_created_total[1m])

7f5a7e9a-e6df-11ef-9310-92fbcf53809c.png

啟動(dòng)一些采樣目標(biāo)

現(xiàn)在讓我們?cè)黾右恍┎蓸幽繕?biāo)供 Prometheus 進(jìn)行采樣。

使用Node Exporter作為采樣目標(biāo),多關(guān)于它的使用請(qǐng)查閱

# wget https://github.com/prometheus/node_exporter/releases/download/v1.1.2/node_exporter-1.1.2.linux-amd64.tar.gz
# tar -xvzf node_exporter-1.1.2.linux-amd64.tar.gz
# ./node_exporter --web.listen-address 127.0.0.1:8001
# ./node_exporter --web.listen-address 127.0.0.1:8002
# ./node_exporter --web.listen-address 127.0.0.1:8003

現(xiàn)在,應(yīng)該存在監(jiān)聽http://localhost:8080/metrics, http://localhost:8081/metrics 和http://localhost:8082/metrics的示例目標(biāo)

配置 Prometheus 來監(jiān)控示例目標(biāo)

現(xiàn)在,我們將配置 Prometheus 來采樣這些新目標(biāo)。讓我們將所有三個(gè) endpoint 分組為一個(gè)稱為 “node” 的 job。但是,假設(shè)前兩個(gè) endpoint 是生產(chǎn)目標(biāo),而第三個(gè) endpoint 代表金絲雀實(shí)例。為了在 Prometheus 中對(duì)此建模,我們可以將多個(gè)端組添加到單個(gè) job 中,并為每個(gè)目標(biāo)組添加額外的標(biāo)簽。在此示例中,我們將group=“ production”標(biāo)簽添加到第一個(gè)目標(biāo)組,同時(shí)將group=“ canary”添加到第二個(gè)目標(biāo)。

為此,請(qǐng)將以下job定義添加到prometheus.yml中的scrape_configs部分,然后重新啟動(dòng) Prometheus 實(shí)例。修改后的prometheus.yml內(nèi)容如下

global:
  scrape_interval:     15s # 默認(rèn),每15秒采樣一次目標(biāo)

  # 與其它外部系統(tǒng)(比如federation, remote storage, Alertmanager)交互時(shí),會(huì)附加這些標(biāo)簽到時(shí)序數(shù)據(jù)或者報(bào)警
  external_labels:
    monitor: 'codelab-monitor'

# 一份采樣配置僅包含一個(gè) endpoint 來做采樣
# 下面是 Prometheus 本身的endpoint:
scrape_configs:
  # job_name 將被被當(dāng)作一個(gè)標(biāo)簽 `job=`添加到該配置的任意時(shí)序采樣.
  - job_name: 'prometheus'

    # 覆蓋全局默認(rèn)值,從該job每5秒對(duì)目標(biāo)采樣一次
    scrape_interval: 5s

    static_configs:
      - targets: ['10.118.71.170:9090']

  - job_name: 'node'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:8001', 'localhost:8002']
        labels:
          group: 'production'

      - targets: ['localhost:8003']
        labels:
          group: 'canary'

查看Targets(Status->Targets)

7f6f2dc2-e6df-11ef-9310-92fbcf53809c.png

Graph查詢

7f92cdc2-e6df-11ef-9310-92fbcf53809c.png

配置規(guī)則以將采樣的數(shù)據(jù)聚合到新的時(shí)間序列

盡管在我們的示例中并不會(huì)有問題,但是在聚集了數(shù)千個(gè)時(shí)間序列中查詢時(shí)可能會(huì)變慢。為了提高效率,Prometheus 允許通過配置的記錄規(guī)則將表達(dá)式預(yù)記錄到全新的持久化的時(shí)間序列中。假設(shè)我們感興趣的是 5 分鐘的窗口內(nèi)測得的每個(gè)實(shí)例的所有cpu上平均的cpu時(shí)間(node_cpu_seconds_total,保留 Job,instance,和mode 維度))。我們可以這樣寫:

avg by (job, instance, mode) (rate(node_cpu_seconds_total[5m]))

Graph中執(zhí)行查詢,結(jié)果如下

7fc71302-e6df-11ef-9310-92fbcf53809c.png

現(xiàn)在,要將由該表達(dá)式產(chǎn)生的時(shí)間序列記錄到一個(gè)名為:job_instance_modeavg_rate5m的新指標(biāo),使用以下記錄規(guī)則創(chuàng)建文件并將其保存prometheus.rules.yml

groups:
- name: cpu-node
  rules:
  - record: job_instance_modeavg_rate5m
    expr: avg by (job, instance, mode) (rate(node_cpu_seconds_total[5m]))

在prometheus.yml中添加rule_files語句,以便 Prometheus 選擇此新規(guī)則。現(xiàn)在,prometheus.yml配置應(yīng)如下所示:

global:
  scrape_interval:     15s # 默認(rèn),每15秒采樣一次目標(biāo)

  # 與其它外部系統(tǒng)(比如federation, remote storage, Alertmanager)交互時(shí),會(huì)附加這些標(biāo)簽到時(shí)序數(shù)據(jù)或者報(bào)警
  external_labels:
    monitor: 'codelab-monitor'

rule_files:
  - 'prometheus.rules.yml'

# 一份采樣配置僅包含一個(gè) endpoint 來做采樣
# 下面是 Prometheus 本身的endpoint:
scrape_configs:
  # job_name 將被被當(dāng)作一個(gè)標(biāo)簽 `job=`添加到該配置的任意時(shí)序采樣.
  - job_name: 'prometheus'

    # 覆蓋全局默認(rèn)值,從該job每5秒對(duì)目標(biāo)采樣一次
    scrape_interval: 5s

    static_configs:
      - targets: ['10.118.71.170:9090']

  - job_name: 'node'

    # Override the global default and scrape targets from this job every 5 seconds.
    scrape_interval: 5s

    static_configs:
      - targets: ['localhost:8001', 'localhost:8002']
        labels:
          group: 'production'

      - targets: ['localhost:8003']
        labels:
          group: 'canary'

通過新的配置重新啟動(dòng) Prometheus,并通過expression brower查詢job_instance_modeavg_rate5m,結(jié)果如下

7fee26ea-e6df-11ef-9310-92fbcf53809c.png

鏈接:https://www.cnblogs.com/shouke/p/18667439

聲明:本文內(nèi)容及配圖由入駐作者撰寫或者入駐合作網(wǎng)站授權(quán)轉(zhuǎn)載。文章觀點(diǎn)僅代表作者本人,不代表電子發(fā)燒友網(wǎng)立場。文章及其配圖僅供工程師學(xué)習(xí)之用,如有內(nèi)容侵權(quán)或者其他違規(guī)問題,請(qǐng)聯(lián)系本站處理。 舉報(bào)投訴
  • 監(jiān)控
    +關(guān)注

    關(guān)注

    6

    文章

    2238

    瀏覽量

    55387
  • Prometheus
    +關(guān)注

    關(guān)注

    0

    文章

    28

    瀏覽量

    1732

原文標(biāo)題:從零開始掌握Prometheus:企業(yè)級(jí)監(jiān)控與報(bào)警系統(tǒng)的最佳實(shí)踐

文章出處:【微信號(hào):magedu-Linux,微信公眾號(hào):馬哥Linux運(yùn)維】歡迎添加關(guān)注!文章轉(zhuǎn)載請(qǐng)注明出處。

收藏 人收藏

    評(píng)論

    相關(guān)推薦

    Prometheus的架構(gòu)原理監(jiān)控”談起

    Prometheus是繼Kubernetes(k8s)之后,CNCF畢業(yè)的第二個(gè)開源項(xiàng)目,其來源于Google的Borgmon。本文監(jiān)控這件事說起,深入淺出Prometheus的架構(gòu)
    的頭像 發(fā)表于 10-10 15:47 ?4539次閱讀
    <b class='flag-5'>Prometheus</b>的架構(gòu)原理<b class='flag-5'>從</b>“<b class='flag-5'>監(jiān)控</b>”談起

    Prometheus的基本原理與開發(fā)指南

    ? 導(dǎo)讀??? ? 本文由梯度科技云管研發(fā)部高級(jí)工程師周宇明撰寫,共分為7章,緊密圍繞Prometheus的基本原理與開發(fā)指南展開介紹: 監(jiān)控系統(tǒng)概述
    的頭像 發(fā)表于 11-09 10:45 ?1216次閱讀
    <b class='flag-5'>Prometheus</b>的基本原理與開發(fā)<b class='flag-5'>指南</b>

    SAS走進(jìn)企業(yè)級(jí)存儲(chǔ)應(yīng)用

    SAS走進(jìn)企業(yè)級(jí)存儲(chǔ)應(yīng)用串行SCSI(SAS)的出現(xiàn)已經(jīng)有幾年了。2005年,在主要的接口技術(shù)中,由于OEM服務(wù)器制造商和系統(tǒng)集成商開始提供串行SCSI解決方案,企業(yè)級(jí)存儲(chǔ)市場將會(huì)顯現(xiàn)革命性的進(jìn)展
    發(fā)表于 11-13 21:58

    采用nvSRAM確保企業(yè)級(jí)SSD故障時(shí)電源可靠性

    數(shù)據(jù)傳輸速度超過了NAND閃存的寫入速度,因此企業(yè)級(jí)SSD的寫入性能可通過高速數(shù)據(jù)緩存加以提高。企業(yè)級(jí)SSD通常采用SDRAM作為緩存,保存并處理存儲(chǔ)系統(tǒng)控制器接收到的數(shù)據(jù)流有關(guān)部分
    發(fā)表于 09-26 09:44

    大話企業(yè)級(jí)Android開發(fā)

    大話企業(yè)級(jí)Android開發(fā)
    發(fā)表于 07-11 19:39

    大話企業(yè)級(jí)Android開發(fā)

    大話企業(yè)級(jí)Android開發(fā)
    發(fā)表于 03-31 11:37

    企業(yè)級(jí)的LInux系統(tǒng)日志管理

    企業(yè)級(jí)LInux系統(tǒng)日志管理
    發(fā)表于 05-29 11:33

    prometheus監(jiān)控服務(wù)的整個(gè)流程介紹

    Prometheus,然后Prometheus通過定期拉取的方式來獲取監(jiān)控數(shù)據(jù);數(shù)據(jù)的來源多種多樣包括:系統(tǒng)級(jí)
    發(fā)表于 12-23 17:34

    大話企業(yè)級(jí)Android開發(fā)

    大話企業(yè)級(jí)Android開發(fā)
    發(fā)表于 03-05 11:15

    iPhone OS企業(yè)級(jí)部署指南

    iPhone OS企業(yè)級(jí)部署指南
    發(fā)表于 12-10 14:51 ?57次下載

    戴爾“企業(yè)級(jí)”視頻監(jiān)控解決方案

    戴爾提供整套包括采集、傳輸、處理、存儲(chǔ)、分析和視頻云相關(guān)的視頻監(jiān)控解決方案。結(jié)合高可靠、高兼容和性能強(qiáng)大的企業(yè)級(jí)承載平臺(tái),除了可滿足基本的視頻采集和存儲(chǔ)需求外,戴爾整體視頻監(jiān)控解決方
    發(fā)表于 11-25 15:37 ?1425次閱讀
    戴爾“<b class='flag-5'>企業(yè)級(jí)</b>”視頻<b class='flag-5'>監(jiān)控</b>解決方案

    基于企業(yè)級(jí)信息集成平臺(tái)的數(shù)據(jù)存儲(chǔ)備份系統(tǒng)構(gòu)建_王永平

    基于企業(yè)級(jí)信息集成平臺(tái)的數(shù)據(jù)存儲(chǔ)備份系統(tǒng)構(gòu)建_王永平
    發(fā)表于 03-16 10:10 ?0次下載

    使用Thanos+Prometheus+Grafana構(gòu)建監(jiān)控系統(tǒng)

    對(duì)于彈性伸縮和高可用的系統(tǒng)來說,一般有大量的指標(biāo)數(shù)據(jù)需要收集和存儲(chǔ),如何為這樣的系統(tǒng)打造一個(gè)監(jiān)控方案呢?本文介紹了如何使用 Thanos+Prometheus+Grafana
    的頭像 發(fā)表于 05-05 21:14 ?2717次閱讀

    基于kube-prometheus的大數(shù)據(jù)平臺(tái)監(jiān)控系統(tǒng)設(shè)計(jì)

    本文介紹了如何基于 kube-prometheus 設(shè)計(jì)一個(gè)監(jiān)控系統(tǒng), 以靈活簡單的方式對(duì) kubernetes 上的應(yīng)用進(jìn)行指標(biāo)采集,并實(shí)現(xiàn)監(jiān)控報(bào)
    的頭像 發(fā)表于 05-30 17:02 ?712次閱讀

    構(gòu)建企業(yè)級(jí)文件管理系統(tǒng),輕松搭建 Seafile 社區(qū)版云存儲(chǔ)解決方案

    前言 隨著企業(yè)數(shù)據(jù)量的激增,構(gòu)建一個(gè)安全、高效的企業(yè)級(jí)文件管理系統(tǒng)至關(guān)重要。華為 Flexus X 服務(wù)器,以其靈活的資源配置與卓越的性能,成為部署 Seafile 社區(qū)版云存儲(chǔ)解決方
    的頭像 發(fā)表于 01-13 11:14 ?351次閱讀
    <b class='flag-5'>構(gòu)建</b><b class='flag-5'>企業(yè)級(jí)</b>文件管理<b class='flag-5'>系統(tǒng)</b>,輕松搭建 Seafile 社區(qū)版云存儲(chǔ)解決方案