“ up {}”语法是什么意思?

时间:2019-02-05 16:03:07

标签: syntax prometheus grafana-templating

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

$jobs = label_values(job)

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

我知道$ jobs是一个正在创建的变量,但是我几乎不知道up命令在做什么。我已经上网了,我无法真正缩小搜索范围,无法找到'up'haha这样的通用词

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

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

1 个答案:

答案 0 :(得分:0)

根据Jobs and instances 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时间序列对于实例可用性监视很有用。