Skip to content

Commit

Permalink
better error messages and db management (#997)
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws authored Nov 5, 2024
1 parent d5f9693 commit c6df4b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cid/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,9 +362,9 @@ def get_template_parameters(self, parameters: dict, param_prefix: str='', others
try:
res_list = self.athena.query(query)
except (self.athena.client.exceptions.ClientError, CidError, CidCritical) as exc:
raise CidCritical(f'Failed fetching parameter {prefix}{key}: {exc}') from exc
raise CidCritical(f'Failed fetching parameter {prefix}{key}: {exc}.') from exc
if not res_list:
raise CidCritical(f'Failed fetching parameter {prefix}{key}, {value}. Athena returns empty results')
raise CidCritical(f'Failed fetching parameter {prefix}{key}, {value}. Athena returns empty results. {value.get("error")}')
elif len(res_list) == 1:
params[key] = '-'.join(res_list[0])
else:
Expand Down
23 changes: 20 additions & 3 deletions dashboards/cora/cora.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6708,7 +6708,7 @@ datasets:
RelationalTable:
DataSourceArn: ${athena_datasource_arn}
Catalog: AwsDataCatalog
Schema: ${athena_database_name}
Schema: ${account_map_database_name}
Name: account_map
InputColumns:
- Name: account_id
Expand All @@ -6719,7 +6719,7 @@ datasets:
RelationalTable:
DataSourceArn: ${athena_datasource_arn}
Catalog: AwsDataCatalog
Schema: ${athena_database_name}
Schema: ${data_exports_database_name}
Name: cora_view
InputColumns:
- Name: account_id
Expand Down Expand Up @@ -6852,10 +6852,25 @@ datasets:
- cora_view
schedules:
- default
parameters:
account_map_database_name:
type: athena
query: SELECT DISTINCT table_schema FROM information_schema.columns WHERE table_name = 'account_map'
error: You need to install Foundational Dashboards that provide account_map view.
default: cid_cur
description: Database of account_map table (from foundational dashboards)
global: True
data_exports_database_name:
type: athena
query: SELECT DISTINCT table_schema FROM information_schema.columns WHERE table_name = 'coh'
error: Please check if you have CID Data Exports installed and Cost Optimization Hub option is activated
default: cid_data_export
description: Database of cid data exports
global: True
views:
cora_view:
data: |-
CREATE OR REPLACE VIEW "${athena_database_name}"."cora_view" AS
CREATE OR REPLACE VIEW "${data_exports_database_name}"."cora_view" AS
SELECT
"account_id"
, "action_type"
Expand Down Expand Up @@ -6891,6 +6906,8 @@ views:
WHERE (CAST("date" AS date) >= ("date_trunc"('month', current_timestamp) - INTERVAL '6' MONTH))
parameters:
data_exports_database_name:
type: athena
query: SELECT DISTINCT table_schema FROM information_schema.columns WHERE table_name = 'coh'
default: cid_data_export
description: Database of cid data exports
global: True

0 comments on commit c6df4b7

Please sign in to comment.