Amazon Athena を使用してコストと使用状況レポートにクエリを実行したときに、最新の請求データが表示されないのはなぜですか?

所要時間3分
0

Amazon Athena を使用してコストと使用状況レポートにクエリを実行したときに、最新の請求データが表示されません。

解決方法

この問題の最も一般的な原因は、コストと使用状況レポートテーブルにパーティションがないことです。この問題を解決するには、以下の解決方法のうち 1 つ以上を選択してください。

手動で作成したコストと使用状況レポートテーブルのテーブルパーティションをロードする

コストと使用状況レポートテーブルを手動で作成した場合は、Amazon Athena コンソールで MCSK REPAIR TABLE コマンドを実行して、テーブルパーティションをロードします。または、Amazon Athena コンソールからパーティションをアップロードできます。

テーブルにパーティションを定期的に追加する AWS Glue クローラーを設定している場合は、レポートを生成する前にクローラーが実行されるようスケジュールされていることを確認してください。そうしないと、クエリ結果に最新の請求データが表示されない可能性があります。

Amazon Simple Storage Service (Amazon S3) のパスおよび AWS Glue クローラーを確認する

AWS CloudFormation テンプレートを使用して、コストと使用状況レポートを Athena と統合できます。このテンプレートには、AWS Glue クローラー、AWS Glue データベース、および AWS Lambda イベントが含まれます。コストと使用状況レポートファイルが、新たに Amazon S3 パスに配信されると、Lambda 関数は AWS Glue クローラーを開始します。その後、コストと使用状況レポートファイルのデータに基づいて、クローラーによりテーブルにパーティションが自動的に追加されます。テーブルのクエリ時に最新の請求データを表示できない場合は、S3 のパスを確認してください。コストと使用状況レポートファイルが配信されていることを確認してください。また、AWS Glue クローラーを確認して、ステータスが 「RUNNING (実行中)」または「FAILED (失敗)」でないことを確認してください。

パーティションプロジェクションを使用してパーティションを自動的に格納する

パーティションプロジェクションを使用して、コストと使用状況レポートテーブルを作成できます。パーティションプロジェクションでは、パーティションの値と場所は、AWS Glue データカタログに物理的に保存されるのではなく、動的に計算されます。そのため、最新のデータを表示するためにパーティションを手動で追加する必要はありません。レポートファイルが Amazon S3 バケットに配信された後、すぐにクエリを実行できます。

パーティションプロジェクションを使用してコストと使用状況レポートテーブルを作成するには、次の手順を実行します。

注: コストと使用状況レポートの作成時、[レポートデータ統合の有効化] で [Athena] を選択していることを確認してください。レポートとの統合のために Athena を選択すると、レポートファイルはパーティション化された Parquet 形式でターゲットアカウントに配信されます。レポートファイルがターゲットファイルに配信されるまで、最大 24 時間かかる場合があります。ファイルパスは、次のようになります。

s3://example-report-prefix/example-report-name/example-report-name/year=2021/month=1
s3://example-report-prefix/example-report-name/example-report-name/year=2021/month=2

1.    Amazon Athena コンソールを開きます。

2.    [クエリエディタ] タブで、次のようなコマンドを入力します。

CREATE EXTERNAL TABLE test_cur_partitionprojection(
  `identity_line_item_id` string,
  `identity_time_interval` string,
  `bill_invoice_id` string,
  `bill_billing_entity` string,
  `bill_bill_type` string,
  `bill_payer_account_id` string,
  `bill_billing_period_start_date` timestamp,
  `bill_billing_period_end_date` timestamp,
  `line_item_usage_account_id` string,
  `line_item_line_item_type` string,
  `line_item_usage_start_date` timestamp,
  `line_item_usage_end_date` timestamp,
  `line_item_product_code` string,
  `line_item_usage_type` string,
  `line_item_operation` string,
  `line_item_availability_zone` string,
  `line_item_usage_amount` double,
  `line_item_normalization_factor` double,
  `line_item_normalized_usage_amount` double,
  `line_item_currency_code` string,
  `line_item_unblended_rate` string,
  `line_item_unblended_cost` double,
  `line_item_blended_rate` string,
  `line_item_blended_cost` double,
  `line_item_line_item_description` string,
  `line_item_tax_type` string,
  `line_item_legal_entity` string,
  `product_product_name` string,
  `product_alarm_type` string,
  `product_availability` string,
  `product_bundle` string,
  `product_bundle_description` string,
  `product_bundle_group` string,
  `product_capacitystatus` string,
  `product_clock_speed` string,
  `product_component` string,
  `product_compute_type` string,
  `product_content_type` string,
  `product_cputype` string,
  `product_current_generation` string,
  `product_database_engine` string,
  `product_dedicated_ebs_throughput` string,
  `product_deployment_option` string,
  `product_description` string,
  `product_durability` string,
  `product_ecu` string,
  `product_edition` string,
  `product_engine_code` string,
  `product_enhanced_networking_supported` string,
  `product_event_type` string,
  `product_free_query_types` string,
  `product_free_trial` string,
  `product_from_location` string,
  `product_from_location_type` string,
  `product_gpu` string,
  `product_gpu_memory` string,
  `product_group` string,
  `product_group_description` string,
  `product_instance_family` string,
  `product_instance_name` string,
  `product_instance_type` string,
  `product_instance_type_family` string,
  `product_intel_avx2_available` string,
  `product_intel_avx_available` string,
  `product_intel_turbo_available` string,
  `product_license` string,
  `product_license_model` string,
  `product_location` string,
  `product_location_type` string,
  `product_logs_destination` string,
  `product_max_iops_burst_performance` string,
  `product_max_iopsvolume` string,
  `product_max_throughputvolume` string,
  `product_max_volume_size` string,
  `product_maximum_extended_storage` string,
  `product_maximum_storage_volume` string,
  `product_memory` string,
  `product_memorytype` string,
  `product_message_delivery_frequency` string,
  `product_message_delivery_order` string,
  `product_min_volume_size` string,
  `product_minimum_storage_volume` string,
  `product_network_performance` string,
  `product_normalization_size_factor` string,
  `product_operating_system` string,
  `product_operation` string,
  `product_origin` string,
  `product_physical_cpu` string,
  `product_physical_gpu` string,
  `product_physical_processor` string,
  `product_pre_installed_sw` string,
  `product_processor_architecture` string,
  `product_processor_features` string,
  `product_product_family` string,
  `product_queue_type` string,
  `product_recipient` string,
  `product_region` string,
  `product_resource_type` string,
  `product_rootvolume` string,
  `product_routing_target` string,
  `product_routing_type` string,
  `product_running_mode` string,
  `product_servicecode` string,
  `product_servicename` string,
  `product_sku` string,
  `product_software_included` string,
  `product_software_type` string,
  `product_standard_storage_retention_included` string,
  `product_storage` string,
  `product_storage_class` string,
  `product_storage_media` string,
  `product_storage_type` string,
  `product_subscription_type` string,
  `product_tenancy` string,
  `product_to_location` string,
  `product_to_location_type` string,
  `product_transfer_type` string,
  `product_usagetype` string,
  `product_uservolume` string,
  `product_vcpu` string,
  `product_version` string,
  `product_volume_api_name` string,
  `product_volume_type` string,
  `pricing_rate_id` string,
  `pricing_currency` string,
  `pricing_public_on_demand_cost` double,
  `pricing_public_on_demand_rate` string,
  `pricing_term` string,
  `pricing_unit` string,
  `reservation_amortized_upfront_cost_for_usage` double,
  `reservation_amortized_upfront_fee_for_billing_period` double,
  `reservation_effective_cost` double,
  `reservation_end_time` string,
  `reservation_modification_status` string,
  `reservation_normalized_units_per_reservation` string,
  `reservation_number_of_reservations` string,
  `reservation_recurring_fee_for_usage` double,
  `reservation_start_time` string,
  `reservation_subscription_id` string,
  `reservation_total_reserved_normalized_units` string,
  `reservation_total_reserved_units` string,
  `reservation_units_per_reservation` string,
  `reservation_unused_amortized_upfront_fee_for_billing_period` double,
  `reservation_unused_normalized_unit_quantity` double,
  `reservation_unused_quantity` double,
  `reservation_unused_recurring_fee` double,
  `reservation_upfront_value` double,
  `savings_plan_total_commitment_to_date` double,
  `savings_plan_savings_plan_a_r_n` string,
  `savings_plan_savings_plan_rate` double,
  `savings_plan_used_commitment` double,
  `savings_plan_savings_plan_effective_cost` double,
  `savings_plan_amortized_upfront_commitment_for_billing_period` double,
  `savings_plan_recurring_commitment_for_billing_period` double)
PARTITIONED BY (
  `year` int,
  `month` int)
ROW FORMAT SERDE
  'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
  'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
  's3://example-report-prefix/example-report-name/example-report-name'
TBLPROPERTIES (
  'projection.enabled'='true',
  'projection.month.range'='1,12',
  'projection.month.type'='integer',
  'projection.year.range'='1900,2050',
  'projection.year.type'='integer',
  'storage.location.template'='s3://example-report-prefix/example-report-name/example-report-name/year=${year}/month=${month}')

3.    [別名で保存] を選択して、クエリーを保存します。

4.    [クエリの実行] を選択して、テーブル test_cur_partitionprojection を作成します。

テーブルが作成された後、すぐにテーブルに対してクエリを実行できます。詳細については、「Amazon Athena を使用したコストと使用状況レポートのクエリ」を参照してください。


AWS公式
AWS公式更新しました 3年前