i've been working on some prometheus templating and whenever i look at other examples of templating i keep encountering this command:
$jobs = label_values(job)
$instance = up{job=~"$jobs"}
i understand that $jobs is a variable being created, but i have next to no clue what the up command is doing. I've looked online and i can't really narrow down the search enough for a generic word like 'up' haha
my best guess is that it makes the $instance
variable equal only to cases where job is similar to jobs? i'm really not sure
any help would clarify a bunch. thanks!
According to the Jobs and instances Prometheus documentation:
When Prometheus scrapes a target, it attaches some labels automatically to the scraped time series which serve to identify the scraped target:
job: The configured job name that the target belongs to. instance: The <host>:<port> part of the target's URL that was scraped.
If either of these labels are already present in the scraped data, the behavior depends on the
honor_labels
configuration option.For each instance scrape, Prometheus stores a sample in the following time series:
up{job="<job-name>", instance="<instance-id>"}: 1 if the instance is healthy, i.e. reachable, or 0 if the scrape failed.
The
up
time series is useful for instance availability monitoring.