diff --git a/cfn-templates/cid-cfn.yml b/cfn-templates/cid-cfn.yml index d6543b27f..8af6c526d 100644 --- a/cfn-templates/cid-cfn.yml +++ b/cfn-templates/cid-cfn.yml @@ -61,6 +61,8 @@ Metadata: default: "Deploy KPI Dashboard" OptimizationDataCollectionBucketPath: default: "Path to Optimization Data Collection S3 bucket" + MonthsLookback: + default: "Number of months to lookback in summary_view" DeployTAODashboard: default: "Deploy TAO Dashboard" DeployComputeOptimizerDashboard: @@ -187,6 +189,11 @@ Parameters: Description: The S3 path to the bucket created by the Cost Optimization Data Collection Lab. The path will need point to a folder containing /trusted-advisor and/or /compute-optimizer folders. You can leave the variable {account_id} in place, it will be replaced by current account ID automatically. Default: "s3://cid-data-{account_id}" AllowedPattern: '^s3://[a-zA-Z0-9-_{}/]*$' + MonthsLookback: + Type: String + Description: Number of months of data to capture in summary_view (used on most visuals). Valid range 7 to 24. Default=7 (6 past + 1 current). More months will require more Spice capacity in QuickSight. + Default: "7" + AllowedPattern: '\b(0?[7-9]|1[0-9]|2[0-4])\b' LambdaLayerBucketPrefix: Type: String Description: An S3 bucket with a Lambda layer @@ -1644,6 +1651,7 @@ Resources: quicksight-user: !Ref QuickSightUser account-map-source: 'dummy' #initial share-with-account: !Ref ShareDashboard + view-summary-view-monthsLookback: !Sub '${MonthsLookback}' CUDOSDashboard: Type: Custom::CidDashboard @@ -1664,6 +1672,7 @@ Resources: quicksight-user: !Ref QuickSightUser account-map-source: 'dummy' #initial share-with-account: !Ref ShareDashboard + view-summary-view-monthsLookback: !Sub '${MonthsLookback}' Tags: # Hacky way to manage conditional dependencies - Key: IgnoreNeedCostIntelligenceDashboard Value: !If [NeedCostIntelligenceDashboard, !Ref CostIntelligenceDashboard, ''] @@ -1686,6 +1695,7 @@ Resources: quicksight-user: !Ref QuickSightUser account-map-source: 'dummy' #initial share-with-account: !Ref ShareDashboard + view-summary-view-monthsLookback: !Sub '${MonthsLookback}' Tags: # Hacky way to manage conditional dependencies - Key: IgnoreNeedCostIntelligenceDashboard Value: !If [NeedCostIntelligenceDashboard, !Ref CostIntelligenceDashboard, ''] @@ -1708,6 +1718,7 @@ Resources: quicksight-user: !Ref QuickSightUser account-map-source: 'dummy' #initial share-with-account: !Ref ShareDashboard + view-summary-view-monthsLookback: !Sub '${MonthsLookback}' Tags: # Hacky way to manage conditional dependencies - Key: IgnoreNeedCostIntelligenceDashboard Value: !If [NeedCostIntelligenceDashboard, !Ref CostIntelligenceDashboard, ''] diff --git a/cid/builtin/core/data/queries/cid/summary_view.sql b/cid/builtin/core/data/queries/cid/summary_view.sql index 621a2054f..75318a6d5 100644 --- a/cid/builtin/core/data/queries/cid/summary_view.sql +++ b/cid/builtin/core/data/queries/cid/summary_view.sql @@ -84,7 +84,7 @@ FROM "${cur_table_name}" WHERE - (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH)) - AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH)) + (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '${monthsLookback}' MONTH)) + AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '${monthsLookback}' MONTH)) AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2')) GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,33,34 diff --git a/cid/builtin/core/data/queries/cid/summary_view_ri.sql b/cid/builtin/core/data/queries/cid/summary_view_ri.sql index 8ed01342b..9f55d0ab9 100644 --- a/cid/builtin/core/data/queries/cid/summary_view_ri.sql +++ b/cid/builtin/core/data/queries/cid/summary_view_ri.sql @@ -74,7 +74,7 @@ FROM "${cur_table_name}" WHERE - (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH)) - AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH)) + (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '${monthsLookback}' MONTH)) + AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '${monthsLookback}' MONTH)) AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2')) GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,33,34 diff --git a/cid/builtin/core/data/queries/cid/summary_view_sp.sql b/cid/builtin/core/data/queries/cid/summary_view_sp.sql index fb5b14605..9e0051068 100644 --- a/cid/builtin/core/data/queries/cid/summary_view_sp.sql +++ b/cid/builtin/core/data/queries/cid/summary_view_sp.sql @@ -78,7 +78,7 @@ FROM "${cur_table_name}" WHERE - (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH)) - AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH)) + (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '${monthsLookback}' MONTH)) + AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '${monthsLookback}' MONTH)) AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2')) GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,33,34 diff --git a/cid/builtin/core/data/queries/cid/summary_view_sp_ri.sql b/cid/builtin/core/data/queries/cid/summary_view_sp_ri.sql index a357288fa..e2bde7769 100644 --- a/cid/builtin/core/data/queries/cid/summary_view_sp_ri.sql +++ b/cid/builtin/core/data/queries/cid/summary_view_sp_ri.sql @@ -74,7 +74,7 @@ FROM "${cur_table_name}" WHERE - (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '7' MONTH)) - AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '7' MONTH)) + (("bill_billing_period_start_date" >= ("date_trunc"('month', current_timestamp) - INTERVAL '${monthsLookback}' MONTH)) + AND (CAST("concat"("year", '-', "month", '-01') AS date) >= ("date_trunc"('month', current_date) - INTERVAL '${monthsLookback}' MONTH)) AND "line_item_operation" NOT IN ('EKSPod-EC2','ECSTask-EC2')) GROUP BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34 diff --git a/cid/builtin/core/data/resources.yaml b/cid/builtin/core/data/resources.yaml index acbf89a38..087d58e71 100644 --- a/cid/builtin/core/data/resources.yaml +++ b/cid/builtin/core/data/resources.yaml @@ -308,6 +308,10 @@ views: - savings_plan_savings_plan_effective_cost - savings_plan_total_commitment_to_date - savings_plan_used_commitment + parameters: + monthsLookback: + default: '7' + description: Number of months of data to capture in summary_view (used on most visuals). Valid range 7 to 24. Default=7 (6 past + 1 current). More months will require more Spice capacity in QuickSight. ec2_running_cost: spriFile: cid/ec2_running_cost_sp_ri.sql