Athena + CUR report in Grafana - How to calculate relative time (last month)?

0

Stack - Managed Grafana + Athena and CUR as data.

I'm currently calculating my billing cost using $__timeFilter(line item usage start date) in my query. I'd like to compute the exact cost between the same days in the previous month as well. For example $__timeFilter(line item usage start date) output:

select SUM(line_item_blended_cost + discount_total_discount) from yad2_billing_reports where line_item_usage_start_date BETWEEN TIMESTAMP '2022-08-01 14:56:16' AND TIMESTAMP '2022-08-08 14:56:16'

I would like to get :

select SUM(line_item_blended_cost + discount_total_discount) from yad2_billing_reports where line_item_usage_start_date BETWEEN TIMESTAMP '2022-07-01 14:56:16' AND TIMESTAMP '2022-08-08 14:56:16'

質問済み 2年前450ビュー
2回答
1
承認された回答

I ended up using the query:

select SUM(line_item_blended_cost + discount_total_discount) as cost from $CUR_Table where line_item_usage_start_date > $__timeFrom() - interval '1' month and line_item_usage_start_date < $__timeTo() - interval '1' month

回答済み 2年前
0

Better to use $__timeFrom() and $__timeTo() as per your usecase

AWS
サポートエンジニア
Shubh
回答済み 2年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ