Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prometheus how "up" metrics works

Tags:

prometheus

I'm looking for information how "up" metrics is calculated by Prometheus

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

How Prometheus calculate when

the instance is healthy

I'm using Apache Cassandra with Prometheus and from time to time "up" metrics showing "down". However Cassandra working OK.

like image 518
uszychaha Avatar asked Mar 14 '19 12:03

uszychaha


Video Answer


2 Answers

From the docs:

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

i.e. it is a per scraper / exporter metric which means whether the exporter was available / reachable or not.

like image 89
Elad Amit Avatar answered Sep 21 '22 02:09

Elad Amit


Prometheus automatically adds up metric alongside a few other metrics (such as scrape_duration_seconds, scrape_samples_scraped, scrape_series_added, etc.) when scraping metrics from each configured scrape target - see these docs for more details. The up metric is set to 1 per each successful scrape. It is set to 0 otherwise. The up metric can be set to 0 in the following cases:

  • When scrape target was unreachable during the scrape.
  • When the target didn't return response during the configured timeout. The timeout can be configured via scrape_timeout option. By default it is set to 10 seconds. See more details about this option here.
  • When there was a network issue during the scrape, which prevented from successful scrape.
  • When the scrape target returns incorrect or incomplete response. The response must contain metrics with values in Prometheus text exposition format.

There may be other reasons for failed scrape. The last reason for failed scrape can be inspected at http://prometheus-host:9090/targets page in the error column. See, for example, http://demo.robustperception.io:9090/targets .

like image 38
valyala Avatar answered Sep 22 '22 02:09

valyala