当前位置: 首页 > web >正文

Prometheus使用Recoding Rules优化性能

通过PromQL可以实时对Prometheus中采集到的样本数据进行查询,聚合以及其它各种运算操作。而在某些PromQL较为复杂且计算量较大时,直接使用PromQL可能会导致Prometheus响应超时的情况。这时需要一种能够类似于后台批处理的机制能够在后台完成这些复杂运算的计算,对于使用者而言只需要查询这些运算结果即可。Prometheus通过Recoding Rule规则支持这种后台计算的方式,可以实现对复杂查询的性能优化,提高查询效率。

定义Recoding rules

在Prometheus配置文件中,通过rule_files定义recoding rule规则文件的访问路径。

rule_files:
[ - <filepath_glob> ... ]

每一个规则文件通过以下格式进行定义:

groups:
[ - <rule_group> ]

一个简单的规则文件:

groups:
- name: example
rules:
- record: job:http_inprogress_requests:sum
expr: sum(http_inprogress_requests) by (job)

rule_group的具体配置项如下所示:

# The name of the group. Must be unique within a file.
name: <string>
# How often rules in the group are evaluated.
[ interval: <duration> | default = global.evaluation_interval ]
rules:
[ - <rule> ... ]

与告警规则一致,一个group下可以包含多条规则rule

# The name of the time series to output to. Must be a valid metric name.
record: <string>
# The PromQL expression to evaluate. Every evaluation cycle this is
# evaluated at the current time, and the result recorded as a new set of
# time series with the metric name as given by 'record'.
expr: <string>
# Labels to add or overwrite before storing the result.
labels:
[ <labelname>: <labelvalue> ]

根据规则中的定义,Prometheus会在后台完成expr中定义的PromQL表达式计算,并且将计算结果保存到新的时间序列record中。同时还可以通过labels为这些样本添加额外的标签。

这些规则文件的计算频率与告警规则计算频率一致,

都通过global.evaluation_interval定义:

global:
[ evaluation_interval: <duration> | default = 1m ]

在这里插入图片描述

http://www.xdnf.cn/news/2912.html

相关文章:

  • antd+react实现html图片预览效果
  • 人事管理系统6
  • react-native 安卓APK打包流程
  • 【Linux学习笔记】进程替换和自定义shell
  • 自动化立库/AGV物流仿真详细步骤
  • MarkItDown:如何高效将各类文档转换为适合 LLM 处理的 Markdown 格式
  • Objective-C Block 底层原理深度解析
  • Hearts of Iron IV 钢铁雄心 4 [DLC 解锁] [Windows SteamOS macOS]
  • 基于tabula对pdf中多个excel进行识别并转换成word中的优化(四)
  • 防爆风扇储能轴流风机风量风压如何保障通风安全?
  • dify1.3.1更新又给我们带来了什么?
  • 已知条件概率,反推设计值
  • Vue3取消网络请求的方法(AbortController)
  • android开发中的多线程、数据存储同步功能实现方案和应用场景
  • 【SpringBoot】基于MybatisPlus的博客管理系统(1)
  • 常见的硬盘分类
  • SpringBoot、微服务与AI场景题深度解析
  • neo4j基础操作:命令行增删改查
  • java web 过滤器
  • 华为云IAM用户权限设置主要有哪些问题需要注意?
  • 医疗生态全域智能化:从技术革新到价值重塑的深度探析
  • 激光驱鸟:以科技重构生态防护边界
  • JavaAPI — 包装类与正则表达式
  • 从厨房到云端:从预制菜到云原生
  • kotlin flatMap 变换函数的特点和使用场景
  • SpringBoot Actuator未授权访问漏洞的全面解析与解决方案
  • 【uom】 0 配置文件(Cargo.toml)
  • vscode chrome调试怎么在所有浏览器都好使
  • jmeter-Beashell获取请求body data
  • 音视频之H.265/HEVC网络适配层