VictoriaMetrics部署及vmalert集成釘釘告警

1、部署VictoriaMetrics

cd /usr/local
wget https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.65.0/victoria-metrics-amd64-v1.65.0.tar.gz
mkdir victoria-metrics && tar -xvzf victoria-metrics-amd64-v1.65.0.tar.gz && \
mv victoria-metrics-prod victoria-metrics/victoria-metrics && cd victoria-metrics
nohup ./victoria-metrics -retentionPeriod=30d -storageDataPath=data &

2、配置Prometheus

# 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).external_labels:datacenter: "victoria-1"
# 遠程寫入victoria
remote_write:- url: "http://127.0.0.1:8428/api/v1/write"queue_config:max_samples_per_send: 10000
# Alertmanager configuration
alerting:alertmanagers:- static_configs:- targets:- localhost:9093# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:- "/usr/local/prometheus/rules/rule_node_down.yml"- "/usr/local/prometheus/rules/rule_disk_over.yml"- "/usr/local/prometheus/rules/rule_cpu_over.yml"- "/usr/local/prometheus/rules/rule_memory_over.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  to any timeseries scraped from this config.- job_name: 'prometheus'static_configs:- targets: ['localhost:9090']
#  用于配置victoria- job_name: 'victoria'static_configs:- targets: ['47.105.38.224:8480']- targets: ['47.105.38.224:8481']- targets: ['47.105.38.224:8482']# metrics_path defaults to '/metrics'#     # scheme defaults to 'http'.- job_name: 'consul-prometheus'# metrics_path: "/v1/agent/metrics"scrape_interval: 60sscrape_timeout: 10sscheme: httpparams:format: ['prometheus']#static_configs:#    - targets:#       - 47.105.38.224:8500consul_sd_configs:- server: '47.105.38.224:8500'services: []relabel_configs:- source_labels: [__metrics_path__]separator: ;regex: /metricstarget_label: __metrics_path__replacement: /actuator/prometheusaction: replace- source_labels: ['__meta_consul_tags']regex: '^.*,metrics=true,.*$'action: keep- job_name: "node20_exporter"static_configs:- targets: ["localhost:9100"]- job_name: "node21_exporter"static_configs:- targets: ["172.16.17.21:9100"]    #監控主機- job_name: "node22_exporter"static_configs:- targets: ["172.16.17.22:9100"]- job_name: "node23_exporter"static_configs:- targets: ["172.16.17.23:9100"]    #監控主機- job_name: "alertmanager"static_configs:- targets: ["localhost:9093"]

?

?

3、配置Grafana數據源

4、構建vmalert

從源代碼構建vmalert:

git clone https://github.com/VictoriaMetrics/VictoriaMetrics
cd VictoriaMetrics
make vmalert

構建二進制文件將放置在VictoriaMetrics/bin文件夾中。

5、添加alert.rules

vim alert.rules#rule示例
groups:- name: test-rulerules:- alert: 主機狀態expr: up == 0for: 2mlabels:status: warningannotations:summary: "{{$labels.instance}}:服務器關閉"description: "{{$labels.instance}}:服務器關閉"

6、修改釘釘prometheus-webhook-dingtalk配置文件

vim /usr/local/prometheus-webhook-dingtalk/config.example.yml## Request timeout
# timeout: 5s## Uncomment following line in order to write template from scratch (be careful!)
#no_builtin_template: true## Customizable templates path
templates:- '/usr/local/alertmanager/template/default.tmpl'## You can also override default template using `default_message`
## The following example to use the 'legacy' template from v0.3.0
#default_message:
#  title: '{{ template "legacy.title" . }}'
#  text: '{{ template "legacy.content" . }}'## Targets, previously was known as "profiles"
targets:webhook1:url: https://oapi.dingtalk.com/robot/send?access_token=XXXXXXXX# secret for signaturesecret: SEC000000000000000000000
#  webhook2:
#    url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx
#  webhook_legacy:#   url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxx# Customize template contentmessage:# Use legacy template# title: '{{ template "legacy.title" . }}'text: '{{ template "wechat.default.message" . }}'webhook_mention_all:url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxmention:all: truewebhook_mention_users:url: https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxmention:mobiles: ['156xxxx8827', '189xxxx8325']

?

7、修改alertmanager配置文件

vim /usr/local/alertmanager/alertmanager.ymlglobal:resolve_timeout: 5m # 處理超時時間,默認為5mintemplates:    # 指定郵件模板的路徑,可以使用相對路徑,template/*.tmpl的方式- '/usr/local/alertmanager/template/default.tmpl'
# 定義路由樹信息
route:group_by: [alertname]  # 報警分組依據receiver: ops_notify   # 設置默認接收人group_wait: 30s        # 最初即第一次等待多久時間發送一組警報的通知group_interval: 60s    # 在發送新警報前的等待時間repeat_interval: 1h    # 重復發送告警時間。默認1hroutes:- receiver: ops_notify  # 基礎告警通知人group_wait: 10smatch_re:alertname: 實例存活告警|磁盤使用率告警   # 匹配告警規則中的名稱發送- receiver: info_notify  # 消息告警通知人group_wait: 10smatch_re:alertname: 內存使用率告警|CPU使用率告警|目錄大小告警# 定義基礎告警接收者
receivers:
- name: ops_notifywebhook_configs:- url: http://localhost:8060/dingtalk/webhook1/sendsend_resolved: true  # 警報被解決之后是否通知
#    message: '{{ template "wechat.default.message" . }}'# 定義消息告警接收者
- name: info_notifywebhook_configs:- url: http://localhost:8060/dingtalk/webhook1/sendsend_resolved: true#   message: '{{ template "wechat.default.message" . }}'# 一個inhibition規則是在與另一組匹配器匹配的警報存在的條件下,使匹配一組匹配器的#警報失效的規則。兩個警報必須具有一組相同的標簽。
inhibit_rules:- source_match:severity: 'critical'target_match:severity: 'warning'equal: ['alertname', 'dev', 'instance']

8、啟動vmalert

./bin/vmalert -rule=alert.rules \-datasource.url=http://localhost:8428 \-notifier.url=http://localhost:9093 &

9、查看釘釘告警

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

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

相關文章

論AI GPT跨境貿易架構及其應用

摘要 2023年初,我司啟動了智慧化跨境貿易供應鏈一體化平臺的建設工作。我在該項目中擔任系統架構設計師的職務,主要負責設計平臺系統架構和安全體系架構。該平臺以移動信息化發展為契機,采用”平臺+AI”的模式解決現有應用的集中移動化需求。平臺整體的邏輯復雜,對系統的高…

react之Hooks的介紹、useState與useEffect副作用的使用

react之Hooks的介紹、useState與useEffect副作用的使用 一、Hooks的基本介紹二、useState的使用2.1 簡單使用2.2 數組結構簡化2.3 狀態的讀取和修改2.3 組件的更新過程 三、useEffect的使用3.1 副作用介紹3.2 基本使用3.3 依賴3.4 不要對依賴項撒謊3.5 依賴項可以是空數組3.6 清…

ZZULIOJ 1193: 單科成績排序(結構體專題),Java

ZZULIOJ 1193: 單科成績排序&#xff08;結構體專題&#xff09;&#xff0c;Java 題目描述 有一學生成績表&#xff0c;包括學號、姓名、3門課程成績。請按要求排序輸出&#xff1a;若輸入1&#xff0c;則按第1門課成績降序輸出成績表&#xff0c;若輸入為i&#xff08;1<…

清風數學建模——擬合算法

擬合算法 文章目錄 擬合算法概念 確定擬合曲線最小二乘法的幾何解釋求解最小二乘法matlab求解最小二乘法如何評價擬合的好壞計算擬合優度的代碼 概念 在前面的篇幅中提到可以使用插值算法&#xff0c;通過給定的樣本點推算出一定的曲線從而推算出一些想要的值。但存在一些問題…

解決內網GitLab 社區版 15.11.13項目拉取失敗

問題描述 GitLab 社區版 發布不久&#xff0c;搭建在內網拉取項目報錯&#xff0c;可能提示 unable to access https://github.comxxxxxxxxxxx: Failed to connect to xxxxxxxxxxxxxGit clone error - Invalid argument error:14077438:SSL routines:SSL23_GET_S 15.11.13ht…

QT網絡編程之TCP

QT網絡編程之TCP TCP 編程需要用到倆個類: QTcpServer 和 QTcpSocket。 #------------------------------------------------- # # Project created by QtCreator 2023-08-

mysql截取最后一個字符之前的數據

1、mysql截取最后一個字符之前的數據 select --截取斜杠之前的數據REVERSE(SUBSTR(REVERSE(SPNH-dfg-2012) ; --截取斜杠后的數據 INSTR(REVERSE(SPNH-fg-2012),-)1))2、mysql獲取最后一個字符后的數據 select SUBSTRING_INDEX(SPNH-dfg-2012,-,-1) 3、mysql更新某個字段…

SpringBoot 該如何預防 XSS 攻擊

XSS 漏洞到底是什么&#xff0c;說實話我講不太清楚。但是可以通過遇到的現象了解一下。在前端Form表單的輸入框中&#xff0c;用戶沒有正常輸入&#xff0c;而是輸入了一段代碼&#xff1a;</input><img src1 onerroralert1> 這個正常保存沒有問題。問題出在了列表…

驅動 實現三個燈的亮滅

1、編寫LED燈的驅動&#xff0c;可以控制三個燈&#xff0c;應用程序中編寫控制燈的邏輯&#xff0c;要使用自動創建設備節點機制 head.h #ifndef __HEAD_H__ #define __HEAD_H__#define PHY_LED1_MODER 0x50006000 #define PHY_LED1_ODR 0x50006014 #define PHY_LED1_RCC 0x…

設計模式之責任鏈模式【Java實現】

責任鏈&#xff08;Chain of Resposibility&#xff09; 模式 概念 責任鏈&#xff08;chain of Resposibility&#xff09; 模式&#xff1a;為了避免請求發送者與多個請求處理者耦合在一起&#xff0c;于是將所有請求的處理者 通過前一對象記住其下一個對象的引用而連成一條…

什么是ServiceMesh(Istio一)

現在最火的后端架構無疑是微服務了&#xff0c;微服務將之前的單體應用拆分成了許多獨立的服務應用&#xff0c;每個微服務都是獨立的&#xff0c;好處自然很多&#xff0c;但是隨著應用的越來越大&#xff0c;微服務暴露出來的問題也就隨之而來了&#xff0c;微服務越來越多&a…

【Python】使用python解析普通格式的報文為someip格式報文

文章目錄 1.安裝scapy庫2.示例 1.安裝scapy庫 使用 pip 安裝 scapy 第三方庫&#xff0c;打開 cmd&#xff0c;輸入以下命令&#xff1a; pip install scapy出現如圖所示&#xff0c;表示安裝成功&#xff1a; 2.示例 要解析someip格式報文&#xff0c;需要導入someip模塊&a…

【Spring 】了解Spring AOP

目錄 一、什么是Spring AOP 二、AOP的使用場景 三、AOP組成 四、Spring AOP的實現 1、添加Spring AOP依賴 2、定義切面和切點 3、定義相關通知 五、 AOP的實現原理 1、什么是動態代理 2、 JDK代理和CGLIB代理的區別 一、什么是Spring AOP AOP&#xff08;Aspect Ori…

PLY模型格式詳解【3D】

本文介紹PLY 多邊形文件格式&#xff0c;這是一種用于存儲被描述為多邊形集合的圖形對象。 PLY文件格式的目標是提供一種簡單且易于實現但通用的格式足以適用于各種模型。 PLY有兩種子格式&#xff1a;易于入門的 ASCII 表示形式和用于緊湊存儲和快速保存和加載的二進制格式。 …

【FastColoredTextBox】C# 開源文本編輯控件

主界面截圖 使用Demos演示 FastColoredTextBox 是一個用于在 C# 程序中實現高亮語法著色、代碼編輯和文本顯示的自定義控件。它提供了許多功能&#xff0c;包括&#xff1a; 語法高亮&#xff1a;FastColoredTextBox 支持多種語言的語法高亮&#xff0c;可以根據語法規則將不同…

write javaBean error, fastjson version 1.2.76

fastjson JSON.toJSONString 報錯&#xff1a; > [0] JavaBeanSerializer.java->541: com.alibaba.fastjson.serializer.JavaBeanSerializer->write()> [1] JavaBeanSerializer.java->154: com.alibaba.fastjson.serializer.JavaBeanSerializer->write()>…

vite4+vue3+electron23.3+ts桌面應用bs端開發 打包windows、linux、max三個系統的安裝包

vite4vue3electron23.3ts桌面應用bs端開發 打包windows、linux、max三個系統的安裝包 主要包依賴 "electron-store": "^8.1.0", //全局數據狀態管理&#xff0c;可選擇性安裝"electron": "23.3.8","electron-builder": &q…

Android 使用SQLite的案例詳解

1、說明 sqlite是個輕量級的數據庫,可用于嵌入式。有時候做本地的web開發的時候,我會把sqlite作為內置數據庫,這樣便于部署,直接啟動應用即可。 這里主要是將android中的使用過程記錄一下。主要包含,數據如何初始化,在不同的activity中如何使用,以及增刪改查的實現。 …

網頁顯示攝像頭數據的方法---基于web video server

1. 背景&#xff1a; 在ros系統中有發布攝像頭的相關驅動rgb數據&#xff0c;需求端需要將rgb數據可以直接在網頁上去顯示。 問題解決&#xff1a; web_video_server功能包&#xff0c;相關鏈接&#xff1a; web_video_server - ROS Wiki 2. 下載&#xff0c;安裝和編譯&a…

Ubuntu20 ctrl+alt+T無法打開終端

事情是這樣的&#xff0c;某天改了下python版本&#xff0c;發現linux默認打開終端的快捷鍵ctrlaltT寄了&#xff0c;網上給出的都是修改快捷鍵不出意外肯定沒用 但是幸好我們是會分析的&#xff0c;我看到&#xff0c;很多回答說新增一個快捷鍵運行的命令是gnome-terminal&…