diff --git a/cost/azure/rightsize_sql_instances/CHANGELOG.md b/cost/azure/rightsize_sql_instances/CHANGELOG.md index 67daa476ff..34fe806fb2 100644 --- a/cost/azure/rightsize_sql_instances/CHANGELOG.md +++ b/cost/azure/rightsize_sql_instances/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v5.5.0 + +- Added support for downsizing multiple sizes where appropriate + ## v5.4.2 - Minor code improvements to conform with current standards. Functionality unchanged. diff --git a/cost/azure/rightsize_sql_instances/README.md b/cost/azure/rightsize_sql_instances/README.md index 74583e36c1..0dff292195 100644 --- a/cost/azure/rightsize_sql_instances/README.md +++ b/cost/azure/rightsize_sql_instances/README.md @@ -18,7 +18,7 @@ The policy includes the estimated monthly savings. The estimated monthly savings - The `Estimated Monthly Savings` is calculated by multiplying the amortized cost of the resource for 1 day, as found within Flexera CCO, by 30.44, which is the average number of days in a month. - For unused resources, the `Estimated Monthly Savings` is the full cost of the resource. -- For underutilized resources, the `Estimated Monthly Savings` is the full cost of the resource is divided by the current capacity of the instance, multiplied by the recommended capacity of the instance, and then subtracted from the current cost of the instance. +- For underutilized resources, the savings is the difference of the current cost of the resource and the estimated cost of the recommended resource type. - Since the costs of individual resources are obtained from Flexera CCO, they will take into account any Flexera adjustment rules or cloud provider discounts present in the Flexera platform. - If the resource cannot be found in Flexera CCO, the `Estimated Monthly Savings` is 0. - The incident message detail includes the sum of each resource `Estimated Monthly Savings` as `Potential Monthly Savings`. @@ -46,6 +46,7 @@ The policy includes the estimated monthly savings. The estimated monthly savings - *Statistic Lookback Period* - How many days back to look at connection and CPU utilization data for instances. This value cannot be set higher than 90 because Azure does not retain metrics for longer than 90 days. - *Report Unused or Underutilized* - Whether to report on unused instances, underutilized instances, or both. If both are selected, unused instances will not appear in the list of underutilized instances regardless of CPU usage. - *Underutilized Instance CPU Threshold (%)* - The CPU threshold at which to consider an instance to be underutilized and therefore be flagged for downsizing. +- *Skip Instance Sizes* - Whether to recommend downsizing multiple sizes. When set to 'No', only the next smaller size will ever be recommended for downsizing. When set to 'Yes', more aggressive downsizing recommendations will be made when appropriate. - *Automatic Actions* - When this value is set, this policy will automatically take the selected action(s). Please note that the "Automatic Actions" parameter contains a list of action(s) that can be performed on the resources. When it is selected, the policy will automatically execute the corresponding action on the data that failed the checks, post incident generation. Please leave it blank for *manual* action. diff --git a/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt b/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt index f1e43f39b9..9da210e56e 100644 --- a/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt +++ b/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt @@ -7,7 +7,7 @@ category "Cost" severity "low" default_frequency "weekly" info( - version: "5.4.2", + version: "5.5.0", provider: "Azure", service: "SQL", policy_set: "Rightsize Database Instances", @@ -151,6 +151,15 @@ parameter "param_stats_lookback" do default 30 end +parameter "param_downsize_multiple" do + type "string" + category "Policy Settings" + label "Skip Instance Sizes" + description "Whether to recommend downsizing multiple sizes. When set to 'No', only the next smaller size will ever be recommended for downsizing. When set to 'Yes', more aggressive downsizing recommendations will be made when appropriate." + allowed_values "Yes", "No" + default "No" +end + parameter "param_automatic_action" do type "list" category "Actions" @@ -657,11 +666,11 @@ datasource "ds_azure_sql_resize_map" do end datasource "ds_merged_metrics" do - run_script $js_merged_metrics, $ds_azure_sql_database_metrics, $ds_azure_sql_resize_map, $ds_applied_policy, $param_stats_underutil_threshold_cpu_value, $param_stats_lookback, $param_unused_or_underutilized, $param_stats_threshold + run_script $js_merged_metrics, $ds_azure_sql_database_metrics, $ds_azure_sql_resize_map, $ds_applied_policy, $param_stats_underutil_threshold_cpu_value, $param_stats_lookback, $param_unused_or_underutilized, $param_stats_threshold, $param_downsize_multiple end script "js_merged_metrics", type: "javascript" do - parameters "ds_azure_sql_database_metrics", "ds_azure_sql_resize_map", "ds_applied_policy", "param_stats_underutil_threshold_cpu_value", "param_stats_lookback", "param_unused_or_underutilized", "param_stats_threshold" + parameters "ds_azure_sql_database_metrics", "ds_azure_sql_resize_map", "ds_applied_policy", "param_stats_underutil_threshold_cpu_value", "param_stats_lookback", "param_unused_or_underutilized", "param_stats_threshold", "param_downsize_multiple" result "result" code <<-EOS // Function to calculate percentiles from metrics @@ -804,6 +813,16 @@ script "js_merged_metrics", type: "javascript" do if (typeof(ds_azure_sql_resize_map[tier][type]['down']) == 'string') { instance['newResourceType'] = ds_azure_sql_resize_map[tier][type]['down'] + if (param_downsize_multiple == "Yes") { + type = instance['sku']['name'] + '_' + instance['newResourceType'] + + while (typeof(ds_azure_sql_resize_map[tier][type]['down']) == 'string' && cpu_test_value * 2 <= param_stats_underutil_threshold_cpu_value) { + cpu_test_value = cpu_test_value * 2 + instance['newResourceType'] = ds_azure_sql_resize_map[tier][type]['down'] + type = instance['sku']['name'] + '_' + instance['newResourceType'] + } + } + instance["recommendationDetails"] = [ "Downsize Azure SQL database ", instance["name"], " ", "in Azure Subscription ", instance["subscriptionName"], " ", diff --git a/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances_meta_parent.pt b/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances_meta_parent.pt index f431dd0b7b..48801e159e 100644 --- a/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances_meta_parent.pt +++ b/cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances_meta_parent.pt @@ -7,7 +7,7 @@ category "Meta" default_frequency "15 minutes" info( provider: "Azure", - version: "5.4.2", # This version of the Meta Parent Policy Template should match the version of the Child Policy Template as it appears in the Catalog for best reliability + version: "5.5.0", # This version of the Meta Parent Policy Template should match the version of the Child Policy Template as it appears in the Catalog for best reliability publish: "true", deprecated: "false" ) @@ -176,6 +176,15 @@ parameter "param_stats_lookback" do default 30 end +parameter "param_downsize_multiple" do + type "string" + category "Policy Settings" + label "Skip Instance Sizes" + description "Whether to recommend downsizing multiple sizes. When set to 'No', only the next smaller size will ever be recommended for downsizing. When set to 'Yes', more aggressive downsizing recommendations will be made when appropriate." + allowed_values "Yes", "No" + default "No" +end + parameter "param_automatic_action" do type "list" category "Actions" diff --git a/data/policy_permissions_list/master_policy_permissions_list.json b/data/policy_permissions_list/master_policy_permissions_list.json index 8de58d1b60..f5811f70b7 100644 --- a/data/policy_permissions_list/master_policy_permissions_list.json +++ b/data/policy_permissions_list/master_policy_permissions_list.json @@ -3994,7 +3994,7 @@ { "id": "./cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt", "name": "Azure Rightsize SQL Databases", - "version": "5.4.2", + "version": "5.5.0", "providers": [ { "name": "azure_rm", diff --git a/data/policy_permissions_list/master_policy_permissions_list.yaml b/data/policy_permissions_list/master_policy_permissions_list.yaml index 945861b298..71390cbfa6 100644 --- a/data/policy_permissions_list/master_policy_permissions_list.yaml +++ b/data/policy_permissions_list/master_policy_permissions_list.yaml @@ -2320,7 +2320,7 @@ required: true - id: "./cost/azure/rightsize_sql_instances/azure_rightsize_sql_instances.pt" name: Azure Rightsize SQL Databases - version: 5.4.2 + version: 5.5.0 :providers: - :name: azure_rm :permissions: