windows单节点验证victoriametrics结合AlertManger实现告警推送webhook

devtools/2025/3/26 5:58:57/

安装victoriametrics

https://docs.victoriametrics.com/single-server-victoriametrics/

下载地址

https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.113.0

找到​​victoria-metrics-windows-amd64-v1.113.0.zip​​

https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.113.0/victoria-metrics-windows-amd64-v1.113.0.zip

解压并在cmd里启动

victoria-metrics-windows-amd64-prod.exe

启动结果

......
2025-03-21T07:17:44.495Z        info    VictoriaMetrics/app/vmselect/promql/rollup_result_cache.go:156  loaded rollupResult cache from "victoria-metrics-data/cache/rollupResult" in 0.010 seconds; entriesCount: 0, sizeBytes: 0
2025-03-21T07:17:44.495Z        info    VictoriaMetrics/app/vmselect/prometheus/prometheus.go:1297      limiting -search.maxUniqueTimeseries to 8547304 according to -search.maxConcurrentRequests=16 and remaining memory=27351374234 bytes. To increase the limit, reduce -search.maxConcurrentRequests or increase memory available to the process.
2025-03-21T07:17:44.496Z        info    VictoriaMetrics/app/victoria-metrics/main.go:105        started VictoriaMetrics in 0.203 seconds
2025-03-21T07:17:44.500Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:169        started server at http://0.0.0.0:8428/
2025-03-21T07:17:44.502Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:171        pprof handlers are exposed at http://0.0.0.0:8428/debug/pprof/

访问​​

http://127.0.0.1:8428​​

windows_30">安装vmutils-windows

vmutils-windows包里包含众多VictoriaMetrics组件

https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.113.0/vmutils-windows-amd64-v1.113.0.zip

解压​​vmutils-windows-amd64-v1.113.0.zip​​

启动vmagent

https://docs.victoriametrics.com/vmagent/

启动命令

vmagent-windows-amd64-prod.exe -promscrape.config=prometheus.yml -remoteWrite.url=http://127.0.0.1:8428/api/v1/write

安装victoriametrics

https://docs.victoriametrics.com/single-server-victoriametrics/

下载地址

https://github.com/VictoriaMetrics/VictoriaMetrics/releases/tag/v1.113.0

找到​​victoria-metrics-windows-amd64-v1.113.0.zip​​

https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.113.0/victoria-metrics-windows-amd64-v1.113.0.zip

解压并在cmd里启动

victoria-metrics-windows-amd64-prod.exe

启动结果

......
2025-03-21T07:17:44.495Z        info    VictoriaMetrics/app/vmselect/promql/rollup_result_cache.go:156  loaded rollupResult cache from "victoria-metrics-data/cache/rollupResult" in 0.010 seconds; entriesCount: 0, sizeBytes: 0
2025-03-21T07:17:44.495Z        info    VictoriaMetrics/app/vmselect/prometheus/prometheus.go:1297      limiting -search.maxUniqueTimeseries to 8547304 according to -search.maxConcurrentRequests=16 and remaining memory=27351374234 bytes. To increase the limit, reduce -search.maxConcurrentRequests or increase memory available to the process.
2025-03-21T07:17:44.496Z        info    VictoriaMetrics/app/victoria-metrics/main.go:105        started VictoriaMetrics in 0.203 seconds
2025-03-21T07:17:44.500Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:169        started server at http://0.0.0.0:8428/
2025-03-21T07:17:44.502Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:171        pprof handlers are exposed at http://0.0.0.0:8428/debug/pprof/

访问​​

http://127.0.0.1:8428​​

windows_76">安装vmutils-windows

vmutils-windows包里包含众多VictoriaMetrics组件

https://github.com/VictoriaMetrics/VictoriaMetrics/releases/download/v1.113.0/vmutils-windows-amd64-v1.113.0.zip

解压​​vmutils-windows-amd64-v1.113.0.zip​​

启动vmagent

https://docs.victoriametrics.com/vmagent/

启动命令

vmagent-windows-amd64-prod.exe -promscrape.config=prometheus.yml -remoteWrite.url=http://127.0.0.1:8428/api/v1/write

其中​​prometheus.yml​​​为prometheus配置文件;​​http://127.0.0.1:8428/api/v1/write​​为victoriametrics服务地址

prometheus.yml配置文件内容如下

global:scrape_interval: 15sscrape_configs:- job_name: "victoriametrics"static_configs:- targets: ["127.0.0.1:8429"]- job_name: "zookeeper"static_configs:- targets: ["127.0.0.1:7000"]- job_name: "mysql"static_configs:- targets: ["127.0.0.1:9104"]- job_name: "windows"static_configs:- targets: ["127.0.0.1:9182"]

启动日志如下

2025-03-21T07:32:48.747Z        info    VictoriaMetrics/app/vmagent/main.go:169 started vmagent in 0.380 seconds
2025-03-21T07:32:48.747Z        info    VictoriaMetrics/lib/promscrape/scraper.go:118   reading scrape configs from "prometheus.yml"
2025-03-21T07:32:48.748Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:169        started server at http://0.0.0.0:8429/
2025-03-21T07:32:48.749Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:171        pprof handlers are exposed at http://0.0.0.0:8429/debug/pprof/
2025-03-21T07:32:48.753Z        info    VictoriaMetrics/lib/promscrape/config.go:149    starting service discovery routines...
2025-03-21T07:32:48.754Z        info    VictoriaMetrics/lib/promscrape/config.go:155    started 5 service discovery routines in 0.001 seconds
2025-03-21T07:32:48.754Z        info    VictoriaMetrics/lib/promscrape/scraper.go:439   static_configs: added targets: 5, removed targets: 0; total targets: 5

启动vmalert

https://docs.victoriametrics.com/vmalert/

启动命令

vmalert-windows-amd64-prod.exe -rule=rule-first.yml -datasource.url=http://127.0.0.1:8428 -notifier.url=http://127.0.0.1:9093 -notifier.url=http://127.0.0.1:9093 -remoteWrite.url=http://127.0.0.1:8428 -remoteRead.url=http://127.0.0.1:8428 -external.label=cluster=east-1 -external.label=replica=a

其中rule-first.yml为规则文件;​​http://127.0.0.1:8428​​​为victoriametrics服务地址;​​http://127.0.0.1:9093​​为AlertManger地址。

rule-first.yml规则配置文件内容如下

groups:- name: InstanceDown_Rulerules:- alert: InstanceDown  # 告警名称expr: up == 0        # 告警条件for: 30s              # 告警触发前需要持续满足条件的时间labels:severity: critical # 告警的严重程度instance: "{{$labels.instance}}"annotations:summary: "Instance {{ $labels.instance }} down"description: "Instance {{ $labels.instance }} has been down for more than 30 seconds."

启动日志如下

......
2025-03-21T07:39:41.952Z        info    VictoriaMetrics/app/vmalert/config/log/logger.go:52     found 1 files to read from "Local FS{MatchPattern: \"rule-first.yml\"}"
2025-03-21T07:39:41.955Z        info    VictoriaMetrics/app/vmalert/config/log/logger.go:52     finished reading 1 files in 889.8µs from "Local FS{MatchPattern: \"rule-first.yml\"}"
2025-03-21T07:39:41.956Z        info    VictoriaMetrics/app/vmalert/rule/group.go:497   group "InstanceDown_Rule" will start in 8.357938405s; interval=1m0s; eval_offset=<nil>; concurrency=1
2025-03-21T07:39:41.959Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:169        started server at http://0.0.0.0:8880/
2025-03-21T07:39:41.960Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:171        pprof handlers are exposed at http://0.0.0.0:8880/debug/pprof/访问地址

http://127.0.0.1:8880/

部署AlertManger

下载AlertManger

https://github.com/prometheus/alertmanager/releases

下载地址

https://github.com/prometheus/alertmanager/releases/download/v0.28.1/alertmanager-0.28.1.windows-amd64.zip

解压并启动,启动命令如下

alertmanager.exe --config.file=alertmanager.yml --log.level=debug

其中alertmanager.yml为alertmanager的配置文件,配置文件内容如下:

route:
#  group_by: ['alertname', 'instance', 'job']group_by: [...]group_wait: 10sgroup_interval: 20srepeat_interval: 30sreceiver: 'web.hook'
receivers:- name: 'web.hook'webhook_configs:- url: 'http://127.0.0.1:5001/user/alert'send_resolved: true
#inhibit_rules:
#  - source_match:
#      severity: 'critical'
#    target_match:
#      severity: 'warning'
#    equal: ['alertname', 'instance', 'job']
global:resolve_timeout: 5m​​

http://127.0.0.1:5001/user/alert​​配置推送到应用服务的服务端点

启动日志如下

......
ts=2025-03-21T07:49:26.950Z caller=main.go:348 level=debug externalURL=http://P7507787A244:9093
ts=2025-03-21T07:49:26.951Z caller=coordinator.go:113 level=info component=configuration msg="Loading configuration file" file=alertmanager.yml
ts=2025-03-21T07:49:26.954Z caller=coordinator.go:126 level=info component=configuration msg="Completed loading of configuration file" file=alertmanager.yml
ts=2025-03-21T07:49:26.958Z caller=main.go:495 level=debug routePrefix=/
ts=2025-03-21T07:49:26.960Z caller=tls_config.go:313 level=info msg="Listening on" address=[::]:9093
ts=2025-03-21T07:49:26.962Z caller=tls_config.go:316 level=info msg="TLS is disabled." http2=false address=[::]:9093

访问地址

http://127.0.0.1:9093

其中​​prometheus.yml​​​为prometheus配置文件;​​http://127.0.0.1:8428/api/v1/write​​为victoriametrics服务地址

prometheus.yml配置文件内容如下

global:scrape_interval: 15sscrape_configs:- job_name: "victoriametrics"static_configs:- targets: ["127.0.0.1:8429"]- job_name: "zookeeper"static_configs:- targets: ["127.0.0.1:7000"]- job_name: "mysql"static_configs:- targets: ["127.0.0.1:9104"]- job_name: "windows"static_configs:- targets: ["127.0.0.1:9182"]

启动日志如下

2025-03-21T07:32:48.747Z        info    VictoriaMetrics/app/vmagent/main.go:169 started vmagent in 0.380 seconds
2025-03-21T07:32:48.747Z        info    VictoriaMetrics/lib/promscrape/scraper.go:118   reading scrape configs from "prometheus.yml"
2025-03-21T07:32:48.748Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:169        started server at http://0.0.0.0:8429/
2025-03-21T07:32:48.749Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:171        pprof handlers are exposed at http://0.0.0.0:8429/debug/pprof/
2025-03-21T07:32:48.753Z        info    VictoriaMetrics/lib/promscrape/config.go:149    starting service discovery routines...
2025-03-21T07:32:48.754Z        info    VictoriaMetrics/lib/promscrape/config.go:155    started 5 service discovery routines in 0.001 seconds
2025-03-21T07:32:48.754Z        info    VictoriaMetrics/lib/promscrape/scraper.go:439   static_configs: added targets: 5, removed targets: 0; total targets: 5

启动vmalert

https://docs.victoriametrics.com/vmalert/

启动命令

vmalert-windows-amd64-prod.exe -rule=rule-first.yml -datasource.url=http://127.0.0.1:8428 -notifier.url=http://127.0.0.1:9093 -notifier.url=http://127.0.0.1:9093 -remoteWrite.url=http://127.0.0.1:8428 -remoteRead.url=http://127.0.0.1:8428 -external.label=cluster=east-1 -external.label=replica=a

其中rule-first.yml为规则文件;​​http://127.0.0.1:8428​​​为victoriametrics服务地址;​​http://127.0.0.1:9093​​为AlertManger地址。

rule-first.yml规则配置文件内容如下

groups:- name: InstanceDown_Rulerules:- alert: InstanceDown  # 告警名称expr: up == 0        # 告警条件for: 30s              # 告警触发前需要持续满足条件的时间labels:severity: critical # 告警的严重程度instance: "{{$labels.instance}}"annotations:summary: "Instance {{ $labels.instance }} down"description: "Instance {{ $labels.instance }} has been down for more than 30 seconds."

启动日志如下

......
2025-03-21T07:39:41.952Z        info    VictoriaMetrics/app/vmalert/config/log/logger.go:52     found 1 files to read from "Local FS{MatchPattern: \"rule-first.yml\"}"
2025-03-21T07:39:41.955Z        info    VictoriaMetrics/app/vmalert/config/log/logger.go:52     finished reading 1 files in 889.8µs from "Local FS{MatchPattern: \"rule-first.yml\"}"
2025-03-21T07:39:41.956Z        info    VictoriaMetrics/app/vmalert/rule/group.go:497   group "InstanceDown_Rule" will start in 8.357938405s; interval=1m0s; eval_offset=<nil>; concurrency=1
2025-03-21T07:39:41.959Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:169        started server at http://0.0.0.0:8880/
2025-03-21T07:39:41.960Z        info    VictoriaMetrics/lib/httpserver/httpserver.go:171        pprof handlers are exposed at http://0.0.0.0:8880/debug/pprof/

访问地址

http://127.0.0.1:8880/

部署AlertManger

下载AlertManger

https://github.com/prometheus/alertmanager/releases

下载地址

https://github.com/prometheus/alertmanager/releases/download/v0.28.1/alertmanager-0.28.1.windows-amd64.zip

解压并启动,启动命令如下

alertmanager.exe --config.file=alertmanager.yml --log.level=debug

其中alertmanager.yml为alertmanager的配置文件,配置文件内容如下:

route:
#  group_by: ['alertname', 'instance', 'job']group_by: [...]group_wait: 10sgroup_interval: 20srepeat_interval: 30sreceiver: 'web.hook'
receivers:- name: 'web.hook'webhook_configs:- url: 'http://127.0.0.1:5001/user/alert'send_resolved: true
#inhibit_rules:
#  - source_match:
#      severity: 'critical'
#    target_match:
#      severity: 'warning'
#    equal: ['alertname', 'instance', 'job']
global:resolve_timeout: 5m​​

http://127.0.0.1:5001/user/alert​​配置推送到应用服务的服务端点

启动日志如下

......
ts=2025-03-21T07:49:26.950Z caller=main.go:348 level=debug externalURL=http://P7507787A244:9093
ts=2025-03-21T07:49:26.951Z caller=coordinator.go:113 level=info component=configuration msg="Loading configuration file" file=alertmanager.yml
ts=2025-03-21T07:49:26.954Z caller=coordinator.go:126 level=info component=configuration msg="Completed loading of configuration file" file=alertmanager.yml
ts=2025-03-21T07:49:26.958Z caller=main.go:495 level=debug routePrefix=/
ts=2025-03-21T07:49:26.960Z caller=tls_config.go:313 level=info msg="Listening on" address=[::]:9093
ts=2025-03-21T07:49:26.962Z caller=tls_config.go:316 level=info msg="TLS is disabled." http2=false address=[::]:9093

访问地址

http://127.0.0.1:9093

http://www.ppmy.cn/devtools/169136.html

相关文章

检索增强生成(2)本地PDF 本地嵌入模型

from langchain_community.document_loaders import PyPDFLoader from pathlib import Pathdef load_local_pdf(file_path):if not Path(file_path).exists():raise FileNotFoundError(f"文件 {file_path} 不存在&#xff01;")loader PyPDFLoader(file_path)try:do…

【GPT入门】第25课 掌握 LangChain:链式调用的奥秘、特性与使用示例

【GPT入门】第25课 掌握 LangChain&#xff1a;链式调用的奥秘、特性与使用示例 语法解释各部分性质链式调用的性质调用方式注意事项 语法解释 你给出的代码 is_duplicated_chain (check_duplicated | model | parser) 运用了 LangChain 里的链式调用语法。在 LangChain 中&a…

算法2--两数相加

题目描述 解题思路 题目说的很详细了&#xff0c;也就是把每个数倒序写成链表进行输入&#xff0c;然后让你计算两个倒序数组的和&#xff0c;要保证跟预期的结果一样。 首先应该考虑的是两个数组的长度问题&#xff0c;对于链表的每一位进行加法运算&#xff0c;如果两个列表…

Java IO流汇总

Java IO&#xff08;输入/输出&#xff09;流用于处理数据的输入与输出。在Java中&#xff0c;IO流主要分为字节流和字符流&#xff0c;它们又可进一步细分为输入流和输出流。 1. IO流的分类 Java IO流的主要类别如下&#xff1a; 1.1 按数据单位分类 字节流&#xff08;Str…

KNN算法

一、KNN算法介绍 KNN 算法&#xff0c;也称 k邻近算法&#xff0c;是 有监督学习 中的 分类算法 。它可以用于分类或回归问题&#xff0c;但它通常用作分类算法。 二、KNN算法流程 1.计算已知类别数据集中的点与当前点的距离 2.按照距离增次序排序 3.选取与当前点距离最小…

MyBatis注解方式:从CRUD到数据映射的全面解析

目录 1. MyBatis是什么&#xff1f;2.准备工作2.1创建工程2.2 数据准备2.3 持久层代码2.4 单元测试 3.Mybatis的增删改查操作&#xff08;使用注解方式&#xff09;3.1 增&#xff08;insert&#xff09;3.2 删&#xff08;delete&#xff09;3.3 改&#xff08;update&#xf…

Pycharm接入DeepSeek,提升自动化脚本的写作效率

一.效果展示&#xff1a; 二.实施步骤&#xff1a; 1.DeepSeek官网创建API key&#xff1a; 创建成功后&#xff0c;会生成一个API key&#xff1a; 2. PyCharm工具&#xff0c;打开文件->设置->插件&#xff0c;搜索“Continue”&#xff0c;点击安装 3.安装完成后&…

Excel(函数进阶篇):FILTER函数全解读、XLOOKUP函数全解读、UNIQUE函数、数组与数组公式

目录 数组与数组函数office365中VLOOKUP函数的加强数组中的多条件判断FILTER函数详解用法概述函数语法 基础筛选多条件筛选进阶技巧结合动态数组 高级函数整合错误处理注意事项FILTER经典问题&#xff1a;一对多查询 XLOOKUP函数XLOOKUP基础用法XLOOKUP函数多条件匹配和双向查询…