> We can recommend some nice tools to help with this if you give us a better idea of what your setup is like.
In Graphite, I could set the retention on a per metric basis. For daily count metrics it is set to 1 day. A background job fires at say Nov 15 @ 02:00 that aggregates the number of searches performed from Nov 14 00:00 to Nov 15 00:00 and stores them. Everyday this job executes and stores an aggregated count for the last day. Over time, there is 7 days or 30 days or 60 days worth of datapoints. To determine the total number of searches performed in the last 7 days, one would fetch 7 datapoints and aggregate them. Each datapoint represents number of searches performed for that day.
I am trying to do the same with Prometheus, however since Prom features a Pull model, the metric is scraped on Nov 15 at 02:00 for instance. I could get the last day just by issuing an instant query with time set to 02:01. The issue is with getting 7 datapoints for the last 7 days. Since each datapoint could have been set at marginally a different time (02:01, 02:02 etc.), I have overlaps in the datapoints. For instance, Nov 15 uptil 01:59 value was 2, beginning from 02:00 value was 5. I would like Prometheus to return that 5 in this case. With last 7 days case, it is not clear what 'step' should one be using. If I use step=86400 or 1d, we get the datapoint at midnight (00:00) on each of the last 7 days, however that leaves out the datapoint that was set today at 02:00. If I use step=more than one day, then I do get less than 7 datapoints depending on the step.
> Also like Brian said, sum_over_time(metric_name[7d]) should give you what you're looking for.
How does sum_over_time take into account two different values scraped on a day?
00:00 to 01:59, value was 2
01:59 to 23:59, value was 5
Thanks,
Nick
On Tuesday, November 15, 2016 at 6:29:12 PM UTC-5, Ben Kochie wrote:
> What Brian said, you probably want to consider more directly instrumenting this service. We can recommend some nice tools to help with this if you give us a better idea of what your setup is like.
>
>
> Also like Brian said, sum_over_time(metric_name[7d]) should give you what you're looking for.
>
>
> On Tue, Nov 15, 2016 at 11:21 PM, Brian Brazil <
brian....@robustperception.io> wrote:
>
>
>
> On 15 November 2016 at 21:34, Nick <
nikhil.v...@veeva.com> wrote:
> Hello,
>
>
>
> I have a Gauge that tracks number of searches performed per day. Metric’s value is set once a day (somewhere around 2 am). I would like to determine how many searches were performed over the last 7 days.
>
>
>
> This is not how Prometheus is intended to be used. Usually you have many time searies for each of your instances reporting a counter of searches.
>
>
>
> To achieve this, I tried to perform a query such as ‘/api/v1/query_range?start=(-7 days)&end=today(after the metric was set)&step=86400&query=(metric_name)’, however it results in values captured at midnight on each day.
>
>
>
> [1478563200,"2"],[1478649600,"1"],[1478736000,"0"],[1478822400,"0"],[1478908800,"5"],[1478995200,"0"],[1479081600,"0"],[1479168000,"0"]
>
>
>
> As a result, it does not include the value that was set today (say at 2:15 AM) because the last datapoint above is upto midnight (Nov 15 00:00). So, I need to perform an additional (instant) query to retrieve the value that was set at 2:15 AM today.
>
>
>
> api/v1/query?time= 1479176160&query=(metric_name)
>
>
>
> What would be an optimal way to determine how many searches were performed over the last 7 days? Setting the retention to 1D for specific timeseries is not a supported capability, it seems.
>
>
>
> You're looking for sum_over_time.
>
>
> Brian
>
>
> Thanks,
>
> Nick
>
>
>
> --
>
> You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
>
> To unsubscribe from this group and stop receiving emails from it, send an email to
prometheus-devel...@googlegroups.com.
>
> To post to this group, send email to
prometheus...@googlegroups.com.
> To unsubscribe from this group and stop receiving emails from it, send an email to
prometheus-devel...@googlegroups.com.
>
> To post to this group, send email to
prometheus...@googlegroups.com.