首页 > 解决方案 > 'up{}' 语法是什么意思?

问题描述

我一直在研究一些普罗米修斯模板,每当我查看其他模板示例时,我都会遇到这个命令:

$jobs = label_values(job)

$instance = up{job=~"$jobs"}

我知道 $jobs 是一个正在创建的变量,但我几乎不知道 up 命令在做什么。我在网上查看过,我真的无法将搜索范围缩小到足以找到像“up”这样的通用词哈哈

我最好的猜测是它使$instance变量仅等于工作与工作相似的情况?我真的不确定

任何帮助都会澄清一堆。谢谢!

标签: syntaxprometheusgrafana-templating

解决方案


根据Jobs and instances Prometheus 文档:

当 Prometheus 抓取一个目标时,它会自动将一些标签附加到抓取的时间序列上,用于识别抓取的目标:

job: The configured job name that the target belongs to.
instance: The <host>:<port> part of the target's URL that was scraped.

如果这些标签中的任何一个已经存在于抓取的数据中,则行为取决于honor_labels配置选项。

对于每个实例抓取,Prometheus 将样本存储在以下时间序列中:

up{job="<job-name>", instance="<instance-id>"}: 1 if the instance is healthy, i.e. reachable, or 0 if the scrape failed. 

up时间序列对于实例可用性监控很有用。


推荐阅读