好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Prometheus 整合 AlertManager的教程詳解

Prometheus 整合 AlertManager的教程詳解

熱門標簽:漯河電銷外呼系統價格 貴港市機器人外呼系統團隊 蕪湖呼叫中心外呼系統哪家強 天津外呼系統運營商 ec外呼系統怎么樣 征服者快捷酒店地圖標注 貴陽語音電銷機器人 咸陽穩定外呼系統公司 電銷機器人怎么錄音

簡介

Alertmanager 主要用于接收 Prometheus 發送的告警信息,它很容易做到告警信息的去重,降噪,分組,策略路由,是一款前衛的告警通知系統。它支持豐富的告警通知渠道,可以將告警信息轉發到郵箱、企業微信、釘釘等。這一節講解利用AlertManager,把接受到的告警信息,轉發到郵箱。

實驗

準備

啟動 http-simulator 度量模擬器:

docker run --name http-simulator -d -p 8080:8080 pierrevincent/prom-http-simulator:0.1

啟動 Prometheus,為了方便更新配置,使用掛載配置文件的方式:

docker run --name prometheus -d -p 9090:9090 -v /Users/huanchu/Documents/prometheus-data:/prometheus-data \

  prom/prometheus --web.enable-lifecycle --config.file=/prometheus-data/prometheus.yml

啟動添加了參數 --web.enable-lifecycle,讓Prometheus支持通過web端點動態更新配置。

訪問http://127.0.0.1:9090/targets ,Prometheus 自身的 metrics 和 http-simulator 的 metrics 處于up 狀態 ,那么準備工作就做好了。

實驗

實驗1

告警配置

在prometheus-data文件夾下,創建告警配置文件 simulator_alert_rules.yml:

groups:
- name: simulator-alert-rule
 rules:
 - alert: HttpSimulatorDown
 expr: sum(up{job="http-simulator"}) == 0
 for: 1m
 labels:
  severity: critical

配置文件的意思是 http-simulator 服務up狀態為 0 ,并且持續1分鐘時,產生告警 ,級別為 “嚴重的”。

修改prometheus.yml,引用simulator_alert_rules.yml文件,prometheus.yml 內容如下:

global:
 scrape_interval: 5s
 evaluation_interval: 5s
 scrape_timeout: 5s
rule_files:
 - "simulator_alert_rules.yml"
scrape_configs:
 - job_name: 'prometheus'
 static_configs:
 - targets: ['localhost:9090']
 - job_name: 'http-simulator'
 metrics_path: /metrics
 static_configs:
 - targets: ['192.168.43.121:8080']

更新Prometheus配置:

curl -X POST http://localhost:9090/-/reload

訪問http://127.0.0.1:9090/config,可以看到已經為更新了配置:

訪問http://127.0.0.1:9090/rules,Rules 下出現了新添加的告警規則:

驗證

訪問http://127.0.0.1:9090/alerts ,Alerts 下 HttpSimulatorDown 為綠色,處于INACTIVE 狀態,表示什么都沒有發生。

關閉 http-simulator 服務:

docker stop http-simulator

訪問http://127.0.0.1:9090/alerts,HttpSimulatorDown 變成黃色,處于 PENDING 狀態,表示報警即將被激活。

一分鐘后,HttpSimulatorDown 變成紅色,處于 FIRING 狀態,表示報警已經被激活了。

實驗2

告警配置

在simulator_alert_rules.yml文件中增加告警配置:

- alert: ErrorRateHigh
 expr: sum(rate(http_requests_total{job="http-simulator", status="500"}[5m])) / sum(rate(http_requests_total{job="http-simulator"}[5m])) > 0.02
 for: 1m
 labels:
  severity: major
 annotations:
  summary: "High Error Rate detected"
  description: "Error Rate is above 2% (current value is: {{ $value }}"

配置文件的意思是 http-simulator 請求的錯誤率對2% ,并且持續1分鐘時,產生告警 ,級別為 “非常嚴重的”

更新Prometheus配置:

curl -X POST http://localhost:9090/-/reload

驗證

訪問http://127.0.0.1:9090/alerts,ErrorRateHigh 為綠色的 INACTIVE 狀態。

把 http-simulator 的錯誤率調到 10%

curl -H 'Content-Type: application/json' -X PUT -d '{"error_rate": 10}' http://localhost:8080/error_rate

稍等一會后,訪問http://127.0.0.1:9090/alerts, 可以看到錯誤率已經大2%,ErrorRateHigh 為紅色的 FIRING 狀態,報警已經被激活了。

安裝和配置AlertManager

通過docker 掛載文件的方式安裝AlertManager,在本地創建文件夾 alertmanager-data 文件夾,在其中創建 alertmanager.yml,內容如下:

global:
 smtp_smarthost: 'smtp.163.com:25'
 smtp_from: 'xxxxx@163.com'
 smtp_auth_username: 'xxxxx@163.com'
 smtp_auth_password: 'xxxxx'

route:
 group_interval: 1m #當第一個報警發送后,等待'group_interval'時間來發送新的一組報警信息
 repeat_interval: 1m # 如果一個報警信息已經發送成功了,等待'repeat_interval'時間來重新發送他們
 receiver: 'mail-receiver'
receivers:
- name: 'mail-receiver'
 email_configs:
 - to: 'xxxxxx@163.com' 

啟動 AlertManager:

docker run --name alertmanager -d -p 9093:9093 -v /Users/huanchu/Documents/alertmanager-data:/alertmanager-data \

  prom/alertmanager --config.file=/alertmanager-data/alertmanager.yml

在Prometheus目錄下,修改prometheus.yml配置Alertmanager地址:

# Alertmanager configuration
alerting:
 alertmanagers:
 - static_configs:
 - targets:
  - 192.168.43.121:9093

更新Prometheus配置:

curl -X POST http://localhost:9090/-/reload

訪問http://127.0.0.1:9093,訪問Alertmanager UI界面,可以看到接收到ErrorRateHigh告警:

郵箱會收到告警信息:

總結

以上所述是小編給大家介紹的Prometheus 整合 AlertManager的教程詳解,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

標簽:怒江 東營 西寧 濰坊 攀枝花 淮北 香港 西藏

巨人網絡通訊聲明:本文標題《Prometheus 整合 AlertManager的教程詳解》,本文關鍵詞  Prometheus,整合,AlertManager,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Prometheus 整合 AlertManager的教程詳解》相關的同類信息!
  • 本頁收集關于Prometheus 整合 AlertManager的教程詳解的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 四虎影在线永久免费观看| 97高清国语自产拍在线观看| 用力?哦?高潮?喷了娇妻| 最爽的性过程描写| 巜痴汉电车强制肉欲2无码 | caopo丫n草棚在线视频| 久久精品国产国语对白| 胡桃的视频ivk| 美女脱一光二净18以上视频| 最污的网站| 好长?好硬?受不了?描写| 女女同恋のレズビアンbd| 欧美强伦在线观看| jlzz日本人年轻护士出水| 一级做a爰片色欲毛片自慰| 农村真实夫妇屋内偷拍视频| 57pao国产成视频一永久免费| 国产成人免费a在线视频色戒| 三代一起乱H小说| 晚上开车又叫又疼的声音视频下载 | 仁科百华vs黑人巨大dvd| 美国人国语免费观看| 山村村妇野外激战| 巜熟妇的荡欲伦交换4电影| 日本综艺在线观看| 夜夜贪欢〈高H〉| 免费看成年色情影片| 羞羞视频全部网站下载| 99久久伊人精品波多野结衣| 中国河南老妇女bbbbbb| 久久久久久国产精品免费免费四川 | SSS无码视频在线观看| 亚洲免费黄网| 三级免费网站| 玉米地诱子偷伦初尝云雨电影| 农村妇女愉情伦理久久久| 强上女老师| 香蕉成人福利片视频在线观看| 手机看片日韩日韩| 黄色片子在线观看| 女洗澡ⅩXXX裸体XXXX偷窥|