Alex Barysevich
Alex Barysevich

Reputation: 614

Actual timestamp vs Scrape timestamp in Prometheus time series

Here is an example: Scrape interval is set to 30s. Following time series are generated in one scrape cycle by the app:

  1. name: Counter_1, value: 2, timestamp 1590285009
  2. name: Counter_1, value: 4, timestamp 1590285019 (10 second after the first one)
  3. name: Counter_1, value: 0, timestamp 1590285029 (10 second after the second one)

What time series are scraped in this case? All three of them, or the latest one with the timestamp set as a scrape timestamp?

Upvotes: 3

Views: 3595

Answers (2)

yiC
yiC

Reputation: 39

the timestamp Prometheus append to a sample is the time the GET sent

Upvotes: 1

creativeChips
creativeChips

Reputation: 1197

It will store the available data at the moment of scrape, with the scrape timestamp. So, it depends when the scrape happen between steps 1-3. It sounds like you mean it applies only after all of them, and so #3 with the timestamp of the scrape time will be stored. If the scrape happened to occur in between steps 1 and 2, for example, the metrics from #1 will be stored.

In general, when the metrics are "exported", they are made available for scraping, they have no timestamp. The client has no "history" notion (only the server does), only the latest is available to be read. It is a vector of key-value mapped to a numeric value (you can see the format if you scrape it yourself, e.g. curl http://localhost:9100/metrics for typical node_exporter). Periodically the server scrapes the targets and store what is available at that time, with its scrape timestamp.

Upvotes: 4

Related Questions