On 23/12/2020 14:59, Pramod Kumar wrote:
> Hi Clark,
>
> Thank you for quick reply.
> Actually, in my case, the application is generating some numbers (with
> timestamp) and pushing inside file. Now, this number has to be
> consider as counters and shown in prometheus along with the below
> timestamp. e.g.
> 2020-11-25 20:32:19.991(timestamp) 608(value)
> 2020-11-25 20:32:29.991(timestamp)1529(value)
> I want to show this timestamp insted of prometheus scrape time along
> with the counter value.
That is not how Prometheus works. Prometheus is a scrape based metrics
system which records a new value at each scrape for all metrics, rather
than an event system where changes to values are made at times other
than the scrape time. If you want tighter timings around when changes
happened you should look to increase the scraping frequency.
It would be possible to add an additional metric which gives the
timestamp of the last change (and it is quite common to have metrics of
that type).
While the Prometheus text formal does include an optional timestamp
field it should not be used. It is there for a very specific edge case
where metrics are coming from another metrics system (such as AWS
CloudWatch) with some form of delay. Even in that situation the
timestamp should be increasing over scrapes.