Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

better error messages and db management #997

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading