LifeStartsAtHelloWorld
LifeStartsAtHelloWorld

Reputation: 979

Equivalent of Wavefront align in Prometheus

I am trying to move existing dashboards from Wavefront to Prometheus. The metric counter reset every 1 min by the library that pushes the metrics to Wavefront.

Wavefront query:

align(${ds_unit}, sum, sum(ts(metricName_counter, cluster="${cluster_name}" and customer="${customer_name}"), customer))

ds_unit = 1 min. Prometheus query (to replicate the reset after every min in Wavefront I am using increase function):

sum by (customer) (increase(metricName_counter [1m]))

Wavefront sums it up by customer and then buckets it using align and sums again whatever value falls in the bucket. I am not sure if we have something similar in Prometheus.

Upvotes: 0

Views: 436

Answers (1)

Eddie Bracho
Eddie Bracho

Reputation: 1

You can use a subquery to perform a secondary range aggregation

sum_over_time(sum by (customer) (increase(metricName_counter[1m]))[1m:1m])

From the link:

<instant_query> '[' <range> ':' [ <resolution> ] ']' [ offset <duration> ]

  • <instant_query> is equivalent to query field in /query_range API.
  • <range> and offset <duration> is similar to a range selector.
  • <resolution> is optional, which is equivalent to step in /query_range API

Setting offset and duration to the same value emulates what wavefront's align function does, which is accumulate all the points in time bucket and apply an aggregation.

Upvotes: 0

Related Questions