Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-09-09 Thread Prince
Thanks On Thursday, September 2, 2021 at 9:35:57 PM UTC+5:30 bjo...@rabenste.in wrote: > On 31.08.21 04:27, Prince wrote: > > > > for NewMetricWithTimestamp(time.Time,metric) Is it compulsory that the > > time should be in UTC? > > Short answer: No. > > The Go `time.Time` type includes the tim

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-09-02 Thread Bjoern Rabenstein
On 31.08.21 04:27, Prince wrote: > > for NewMetricWithTimestamp(time.Time,metric) Is it compulsory that the > time should be in UTC? Short answer: No. The Go `time.Time` type includes the time zone. It can use any time zone. The library will then use the capabilities of the Go `time.Time` type

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-31 Thread Prince
Thank you. Got It. for NewMetricWithTimestamp(time.Time,metric) Is it compulsory that the time should be in UTC? On Tuesday, August 31, 2021 at 2:14:44 PM UTC+5:30 Stuart Clark wrote: > On 2021-08-30 07:19, Prince wrote: > > So that means in the Prometheus graph the data will be getting > > di

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-31 Thread Stuart Clark
On 2021-08-30 07:19, Prince wrote: So that means in the Prometheus graph the data will be getting displayed from the time of scraping and at a regular intervals (scrape interval). Example: my_metric 1669.574 1630299163151(data and it's timestamp). So this data 1669.574 will be displayed at start

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-29 Thread Prince
So that means in the Prometheus graph the data will be getting displayed from the time of scraping and at a regular intervals (scrape interval). Example: my_metric 1669.574 1630299163151(data and it's timestamp). So this data 1669.574 will be displayed at starting scrape time not at this 16302

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-29 Thread Stuart Clark
The key things you just said were "event" and "logs", both of which are not the metrics that Prometheus is designed for. Now it is possible to convert events/logs into metrics, but this sounds different to what you are wanting. Metrics created from logs would have regularly scraped metrics (wher

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-29 Thread Prince
So let's suppose we are monitoring an event in such a way that the logs of this event are in a file and there is some value for that event and correspondingly time at when we got that value. So in the Prometheus graph we can not show the value at that time Because I have a similar situation

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-29 Thread Ben Kochie
Yup, Prometheus is a monitoring system, not a general use time-series database. Specifically, Prometheus has a "look back window" where Prometheus will take the timestamp of your query and look back in time for samples to match. This is fundamental to how PromQL works. So no, what you are asking

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-29 Thread Stuart Clark
That very much depends on whatever tool you are using to display graphs. However it is sounding like Prometheus may not be the right system depending on what you are trying to do. Prometheus is a metric system, which works by sampling the current state of a system at regular time periods, meanin

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-29 Thread Prince
Is it possible to give a custom timestamp in Prometheus for X-axis ? Example: I* am getting **my_metric_name *152.401 163013412 *at metric endpoint but in Prometheus graph, I am get

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-28 Thread Prince
Thank you, understood. I have used the following: in Collect() * t := time.Date(2021, time.August, 28, 07, 0, 0, 12345678, time.UTC)* *s := prometheus.MustNewConstMetric(c.metric, prometheus.GaugeValue, float64(s.value))* *ch<- prometheus.NewMetricWithTimestamp(t,s)* *I am getting **my

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-25 Thread Julius Volz
So NewMetricWithTimestamp() returns a Metric interface object that you can then emit from a Collector's Collect() method. See this example from cadvisor: https://github.com/google/cadvisor/blob/19df107fd64fa31efc90e186af91b97f38d205e9/metrics/prometheus.go#L1931-L1934 You can see more usage exampl

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-24 Thread Prince
Thank you, As I understood the NewMetricWithTimestamp() takes two parameters one the time and the other one is metric. So as my metric name is go_duration, so I did this : *1st way:* *go func(){* go_duration.WithLabelValues("type").Set(12345.678) prometheus.NewMetricWithTimestamp(time_var, go_d

Re: [prometheus-developers] Adding timestamps to Gauge Metric

2021-08-24 Thread Julius Volz
Hi, You should be able to use the NewMetricWithTimestamp() function for this: https://pkg.go.dev/github.com/prometheus/client_golang/prometheus?utm_source=godoc#NewMetricWithTimestamp Note that client-side timestamps should only be used in exceptional circumstances, and if you still expect those

[prometheus-developers] Adding timestamps to Gauge Metric

2021-08-23 Thread Prince
Hi everyone, I am new to prometheus. I am using type Gauge. I wanted to get the timestamp along with the value. It will be great if anyone can help on this. example: go_duration.WithLabelValues("type").Set(12345.678) so here collector is getting only 12345.678, I am reading this data from a fil