Open6
CURをAthenaで見てみる
CURとは
セットアップ
できるもの
- Database
- athenacurcfn_<環境によって変わる?>
- Table
- cost_and_usage_data_status
- <環境によって変わる?>
cost_and_usage_data_status
テーブルselect status from cost_and_usage_data_status
を実行して、結果がReady
であればクエリ実行可能
もう片方のテーブル
コストデータが入っています。こいつに検索をかけるのであろう
自分の環境ではgeneral_cost
でした
全データを出す
SELECT * FROM "athenacurcfn_general_cost"."general_cost"
unblended_cost
を出す
特定の期間のSELECT SUM(line_item_unblended_cost)
FROM "athenacurcfn_general_cost"."general_cost"
WHERE DATE(line_item_usage_start_date) >= DATE('2023-05-01') AND DATE(line_item_usage_end_date) <= DATE('2023-05-18')
AWSサービス別の利用料金
SELECT line_item_product_code,SUM(line_item_unblended_cost) AS cost
FROM "athenacurcfn_general_cost"."general_cost"
WHERE year = '2023' AND month = '5' AND line_item_usage_account_id = '<AccountID>'
GROUP BY line_item_product_code
ORDER BY line_item_product_code asc, cost desc;
税金の除外
SELECT line_item_product_code,SUM(line_item_unblended_cost) AS cost
FROM "athenacurcfn_general_cost"."general_cost"
WHERE year = '2023' AND month = '5' AND line_item_usage_account_id = '<AccountID>'
AND line_item_line_item_type NOT IN ('Tax', 'Credit', 'DiscountedUsage', 'Fee', 'Refund', 'RiVolumeDiscount')
AND bill_bill_type = 'anniversary'
GROUP BY line_item_product_code
ORDER BY line_item_product_code asc, cost desc;