Custom metric timestamps

453 views
Skip to first unread message

Ahmed Kooli

unread,
Apr 18, 2023, 9:35:06 AM4/18/23
to Prometheus Users
I am using theprometheus_client library on Python to monitor some metrics and these were created in the past (months ago). When I fetch them with Prometheus they are displayed at collection time and I would like to specify a custom timestamp. I tried to create custom metrics and override built-in functions to specify a timestamp but it seems to only work for a short time shift (= custom timestamp - time at collection), does anyone have an idea ? Thanks.

Stuart Clark

unread,
Apr 18, 2023, 2:29:30 PM4/18/23
to Ahmed Kooli, Prometheus Users
The timestamp feature is only really designed for limited situations, such as ingesting metrics from another metric system. Scraping is generally expected to be returning the metric value from "now" (or in the case of coming via another metric system within the last few minutes). As Prometheus is primarily a metric system for metrics around operational systems you want alerts to appear in a timely manner if issues occur.

Ingesting really old data is often needed to backfill metrics, but this is done via a different method to scraping.

Are you able to give a bit more insight around the ingestion of really old data?


On 12 April 2023 08:55:39 BST, Ahmed Kooli <koolia...@gmail.com> wrote:
I am using theprometheus_client library on Python to monitor some metrics and these were created in the past (months ago). When I fetch them with Prometheus they are displayed at collection time and I would like to specify a custom timestamp. I tried to create custom metrics and override built-in functions to specify a timestamp but it seems to only work for a short time shift (= custom timestamp - time at collection), does anyone have an idea ? Thanks.

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
Reply all
Reply to author
Forward
0 new messages