夜莺-Nightingale
夜莺V7
项目介绍 功能概览
部署升级 部署升级
数据接入 数据接入
告警管理 告警管理
数据查看 数据查看
功能介绍 功能介绍
API FAQ
夜莺V6
项目介绍 架构介绍
快速开始 快速开始
黄埔营
安装部署 安装部署
升级
采集器 采集器
使用手册 使用手册
API API
数据库表结构 数据库表结构
FAQ FAQ
开源生态
Prometheus
版权声明
第1章:天降奇兵 第1章:天降奇兵
第2章:探索PromQL 第2章:探索PromQL
第3章:Prometheus告警处理 第3章:Prometheus告警处理
第4章:Exporter详解 第4章:Exporter详解
第5章:数据与可视化 第5章:数据与可视化
第6章:集群与高可用 第6章:集群与高可用
第7章:Prometheus服务发现 第7章:Prometheus服务发现
第8章:监控Kubernetes 第8章:监控Kubernetes
第9章:Prometheus Operator 第9章:Prometheus Operator
参考资料

Use Cases

PromQL variable settings are mainly applied in the following scenarios:

  1. Differentiated Monitoring Configuration

    • Set different alarm thresholds for machines of varying importance
    • Configure specific monitoring rules for particular device groups
  2. Flexible Monitoring Scope Adjustment

    • Quickly switch monitoring target devices
    • Dynamically adjust the coverage of monitoring rules
  3. Batch Rule Management

    • Use the same rule template to adapt to different environments through variables
    • Reduce redundant configurations and improve rule maintenance efficiency

What are Variables?

In the context of alert rules, variables are placeholders that can be referenced when defining alert query conditions but are replaced with specific information when alerts are actually triggered. Using variables makes alert messages more specific and personalized while enabling a single alert template to adapt to different requirements in various situations.

Supported Types

  1. Machine Identifier Variables

In certain scenarios, if you only want to monitor specific network devices, you can use machine identifier variables

Machine Identifier Variables

After defining the variable name, you can use $ident as a placeholder in the promql query condition. Before the query, the variable will be replaced with the machines filtered by the machine identifier above

mem_available_percent{ident="$ident"}>80
  1. Network Device Variables

In scenarios where you only want to monitor certain network devices, you can use network device variables

Network Device Variables

After defining the variable name, you can use $ip as a placeholder in the promql query condition. Before the query, the variable will be replaced with the network devices filtered above

snmp_icmp_packet_loss{agent_host="$ip"}>0
  1. Threshold Variables

In some scenarios, we manage a group of machines where some machines are special and require different alarm thresholds from others. In this case, we can use threshold variables to configure different thresholds for special machines, as shown below

Threshold Variables

In the above configuration, machines in the Default Busi Group all have a threshold of 80. If we want to set special thresholds for two machines in this business group, we can add Variable Filtering below the query condition, select these two machines by machine identifier, and set the threshold to 90. This way, only these two machines will have a threshold of 90, while others remain at 80

  1. Enumeration Variables

In some scenarios, for a particular label, if you only want to monitor certain values, you can use enumeration variables

Enumeration Variables

快猫星云 联系方式 快猫星云 联系方式
快猫星云 联系方式
快猫星云 联系方式
快猫星云 联系方式
快猫星云
OpenSource
开源版
Flashcat
Flashcat