From 123b84afddb177fd21b9fcf6a38af5381b104e54 Mon Sep 17 00:00:00 2001 From: Mario Mupo Date: Mon, 14 Oct 2024 17:14:35 +0200 Subject: [PATCH 1/4] feat: added gate0 autoscale profiles for funcitons auth --- .../citizen-auth-app/04_function_lollipop.tf | 104 +++++++++++++++++ .../07_function_fast_login.tf | 15 ++- .../citizen-auth-app/09_function_profile.tf | 106 +++++++++++++++++- .../09_function_profile_async.tf | 104 +++++++++++++++++ 4 files changed, 327 insertions(+), 2 deletions(-) diff --git a/src/domains/citizen-auth-app/04_function_lollipop.tf b/src/domains/citizen-auth-app/04_function_lollipop.tf index 5bacf10db..49affd594 100644 --- a/src/domains/citizen-auth-app/04_function_lollipop.tf +++ b/src/domains/citizen-auth-app/04_function_lollipop.tf @@ -637,6 +637,110 @@ resource "azurerm_monitor_autoscale_setting" "function_lollipop_itn" { } } } + + profile { + name = "auth_gate0" + + capacity { + default = 10 + minimum = 6 + maximum = 30 + } + + fixed_date { + timezone = "W. Europe Standard Time" + start = "2024-10-15T08:00:00.000Z" + end = "2024-10-15T23:30:00.000Z" + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.function_lollipop_itn.id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Max" + time_window = "PT1M" + time_aggregation = "Maximum" + operator = "GreaterThan" + threshold = 3000 + divide_by_instance_count = true + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.function_lollipop_itn.app_service_plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Max" + time_window = "PT1M" + time_aggregation = "Maximum" + operator = "GreaterThan" + threshold = 35 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "4" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.function_lollipop_itn.id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 300 + divide_by_instance_count = true + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.function_lollipop_itn.app_service_plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 15 + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT2M" + } + } + } } # --------------------------------- diff --git a/src/domains/citizen-auth-app/07_function_fast_login.tf b/src/domains/citizen-auth-app/07_function_fast_login.tf index 498daee95..aeee2afec 100644 --- a/src/domains/citizen-auth-app/07_function_fast_login.tf +++ b/src/domains/citizen-auth-app/07_function_fast_login.tf @@ -217,7 +217,20 @@ module "function_fast_login_itn_autoscale" { normal_load = { minimum = 3 default = 10 - } + }, + gate0 = { + name = "auth_gate0" + minimum = 8 + default = 10 + start = { + hour = 8 + minutes = 00 + } + end = { + hour = 23 + minutes = 30 + } + }, maximum = 30 } diff --git a/src/domains/citizen-auth-app/09_function_profile.tf b/src/domains/citizen-auth-app/09_function_profile.tf index 82cb1a2af..cfe6c0785 100644 --- a/src/domains/citizen-auth-app/09_function_profile.tf +++ b/src/domains/citizen-auth-app/09_function_profile.tf @@ -317,7 +317,7 @@ resource "azurerm_monitor_autoscale_setting" "function_profile" { default = 10 minimum = 5 maximum = 30 - } + }, } ] iterator = profile_info @@ -440,6 +440,110 @@ resource "azurerm_monitor_autoscale_setting" "function_profile" { } } } + + profile { + name = "auth_gate0" + + fixed_date { + timezone = "W. Europe Standard Time" + start = "2024-10-15T08:00:00.000Z" + end = "2024-10-15T23:30:00.000Z" + } + + capacity { + default = 10 + minimum = 5 + maximum = 30 + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.function_profile[count.index].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Max" + time_window = "PT2M" + time_aggregation = "Maximum" + operator = "GreaterThan" + threshold = 2000 + divide_by_instance_count = true + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.function_profile[count.index].app_service_plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Max" + time_window = "PT1M" + time_aggregation = "Maximum" + operator = "GreaterThan" + threshold = 40 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "4" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.function_profile[count.index].id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 200 + divide_by_instance_count = true + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.function_profile[count.index].app_service_plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 15 + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT2M" + } + } + } } ## Alerts diff --git a/src/domains/citizen-auth-app/09_function_profile_async.tf b/src/domains/citizen-auth-app/09_function_profile_async.tf index 861943d1c..0eb5549b8 100644 --- a/src/domains/citizen-auth-app/09_function_profile_async.tf +++ b/src/domains/citizen-auth-app/09_function_profile_async.tf @@ -206,6 +206,110 @@ resource "azurerm_monitor_autoscale_setting" "function_profile_async" { } } } + + profile { + name = "auth_gate0" + + capacity { + default = 10 + minimum = 6 + maximum = 30 + } + + fixed_date { + timezone = "W. Europe Standard Time" + start = "2024-10-15T08:00:00.000Z" + end = "2024-10-15T23:30:00.000Z" + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.function_profile_async.id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT1M" + time_aggregation = "Average" + operator = "GreaterThan" + threshold = 3000 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.function_profile_async.app_service_plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT1M" + time_aggregation = "Average" + operator = "GreaterThan" + threshold = 45 + divide_by_instance_count = false + } + + scale_action { + direction = "Increase" + type = "ChangeCount" + value = "2" + cooldown = "PT1M" + } + } + + rule { + metric_trigger { + metric_name = "Requests" + metric_resource_id = module.function_profile_async.id + metric_namespace = "microsoft.web/sites" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 2000 + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT20M" + } + } + + rule { + metric_trigger { + metric_name = "CpuPercentage" + metric_resource_id = module.function_profile_async.app_service_plan_id + metric_namespace = "microsoft.web/serverfarms" + time_grain = "PT1M" + statistic = "Average" + time_window = "PT5M" + time_aggregation = "Average" + operator = "LessThan" + threshold = 30 + divide_by_instance_count = false + } + + scale_action { + direction = "Decrease" + type = "ChangeCount" + value = "1" + cooldown = "PT20M" + } + } + } } ## Alerts From 83bf70dfdd13b38cfe5f5228e8d0a751d6e799c2 Mon Sep 17 00:00:00 2001 From: Mario Mupo Date: Mon, 14 Oct 2024 17:16:57 +0200 Subject: [PATCH 2/4] fix: minor --- src/domains/citizen-auth-app/09_function_profile.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/domains/citizen-auth-app/09_function_profile.tf b/src/domains/citizen-auth-app/09_function_profile.tf index cfe6c0785..8c65f6005 100644 --- a/src/domains/citizen-auth-app/09_function_profile.tf +++ b/src/domains/citizen-auth-app/09_function_profile.tf @@ -452,7 +452,7 @@ resource "azurerm_monitor_autoscale_setting" "function_profile" { capacity { default = 10 - minimum = 5 + minimum = 8 maximum = 30 } From b32b49c54580881b6b1bf409ac88e12a42a7100b Mon Sep 17 00:00:00 2001 From: Mario Mupo Date: Mon, 14 Oct 2024 17:28:41 +0200 Subject: [PATCH 3/4] fix: increase min to 20 --- src/domains/citizen-auth-app/04_function_lollipop.tf | 2 +- src/domains/citizen-auth-app/07_function_fast_login.tf | 2 +- src/domains/citizen-auth-app/09_function_profile.tf | 2 +- src/domains/citizen-auth-app/09_function_profile_async.tf | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/domains/citizen-auth-app/04_function_lollipop.tf b/src/domains/citizen-auth-app/04_function_lollipop.tf index 49affd594..15c66d049 100644 --- a/src/domains/citizen-auth-app/04_function_lollipop.tf +++ b/src/domains/citizen-auth-app/04_function_lollipop.tf @@ -643,7 +643,7 @@ resource "azurerm_monitor_autoscale_setting" "function_lollipop_itn" { capacity { default = 10 - minimum = 6 + minimum = 20 maximum = 30 } diff --git a/src/domains/citizen-auth-app/07_function_fast_login.tf b/src/domains/citizen-auth-app/07_function_fast_login.tf index aeee2afec..591ccc6f7 100644 --- a/src/domains/citizen-auth-app/07_function_fast_login.tf +++ b/src/domains/citizen-auth-app/07_function_fast_login.tf @@ -220,7 +220,7 @@ module "function_fast_login_itn_autoscale" { }, gate0 = { name = "auth_gate0" - minimum = 8 + minimum = 20 default = 10 start = { hour = 8 diff --git a/src/domains/citizen-auth-app/09_function_profile.tf b/src/domains/citizen-auth-app/09_function_profile.tf index 8c65f6005..a73bc327a 100644 --- a/src/domains/citizen-auth-app/09_function_profile.tf +++ b/src/domains/citizen-auth-app/09_function_profile.tf @@ -452,7 +452,7 @@ resource "azurerm_monitor_autoscale_setting" "function_profile" { capacity { default = 10 - minimum = 8 + minimum = 20 maximum = 30 } diff --git a/src/domains/citizen-auth-app/09_function_profile_async.tf b/src/domains/citizen-auth-app/09_function_profile_async.tf index 0eb5549b8..b7cf337b2 100644 --- a/src/domains/citizen-auth-app/09_function_profile_async.tf +++ b/src/domains/citizen-auth-app/09_function_profile_async.tf @@ -212,7 +212,7 @@ resource "azurerm_monitor_autoscale_setting" "function_profile_async" { capacity { default = 10 - minimum = 6 + minimum = 20 maximum = 30 } From ca43b64ef99b0528d0507aeae73dc366396ab237 Mon Sep 17 00:00:00 2001 From: Andrea Grillo Date: Mon, 14 Oct 2024 23:25:16 +0200 Subject: [PATCH 4/4] fix everything --- .../citizen-auth-app/04_function_lollipop.tf | 242 +----------------- .../07_function_fast_login.tf | 26 -- .../citizen-auth-app/09_function_profile.tf | 51 +--- .../09_function_profile_async.tf | 104 -------- 4 files changed, 21 insertions(+), 402 deletions(-) diff --git a/src/domains/citizen-auth-app/04_function_lollipop.tf b/src/domains/citizen-auth-app/04_function_lollipop.tf index 15c66d049..bbfab74f4 100644 --- a/src/domains/citizen-auth-app/04_function_lollipop.tf +++ b/src/domains/citizen-auth-app/04_function_lollipop.tf @@ -181,7 +181,7 @@ module "function_lollipop_staging_slot_itn" { } resource "azurerm_monitor_autoscale_setting" "function_lollipop_itn" { - name = "${replace(module.function_lollipop_itn.name, "-fn-", "-as-")}-01" + name = replace(module.function_lollipop_itn.name, "-fn-", "-as-") resource_group_name = azurerm_resource_group.lollipop_rg_itn.name location = local.itn_location target_resource_id = module.function_lollipop_itn.app_service_plan_id @@ -191,7 +191,7 @@ resource "azurerm_monitor_autoscale_setting" "function_lollipop_itn" { capacity { default = 10 - minimum = 5 + minimum = 4 maximum = 20 } @@ -299,119 +299,6 @@ resource "azurerm_monitor_autoscale_setting" "function_lollipop_itn" { } } - profile { - name = "night" - - capacity { - default = 10 - minimum = 3 - maximum = 15 - } - - recurrence { - timezone = "W. Europe Standard Time" - hours = [23] - minutes = [0] - days = [ - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Sunday" - ] - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_lollipop_itn.id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Max" - time_window = "PT1M" - time_aggregation = "Maximum" - operator = "GreaterThan" - threshold = 3200 - divide_by_instance_count = true - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "2" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_lollipop_itn.app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Max" - time_window = "PT1M" - time_aggregation = "Maximum" - operator = "GreaterThan" - threshold = 45 - divide_by_instance_count = false - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "3" - cooldown = "PT2M" - } - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_lollipop_itn.id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 500 - divide_by_instance_count = true - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_lollipop_itn.app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 20 - divide_by_instance_count = false - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT2M" - } - } - } - profile { name = "{\"name\":\"default\",\"for\":\"evening\"}" @@ -526,26 +413,17 @@ resource "azurerm_monitor_autoscale_setting" "function_lollipop_itn" { } profile { - name = "{\"name\":\"default\",\"for\":\"night\"}" + name = "wallet_gate0" - recurrence { + fixed_date { timezone = "W. Europe Standard Time" - hours = [5] - minutes = [0] - days = [ - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - "Sunday" - ] + start = "2024-10-15T08:00:00.000Z" + end = "2024-10-15T23:30:00.000Z" } capacity { - default = 10 - minimum = 3 + default = 20 + minimum = 15 maximum = 30 } @@ -638,109 +516,7 @@ resource "azurerm_monitor_autoscale_setting" "function_lollipop_itn" { } } - profile { - name = "auth_gate0" - - capacity { - default = 10 - minimum = 20 - maximum = 30 - } - - fixed_date { - timezone = "W. Europe Standard Time" - start = "2024-10-15T08:00:00.000Z" - end = "2024-10-15T23:30:00.000Z" - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_lollipop_itn.id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Max" - time_window = "PT1M" - time_aggregation = "Maximum" - operator = "GreaterThan" - threshold = 3000 - divide_by_instance_count = true - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "2" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_lollipop_itn.app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Max" - time_window = "PT1M" - time_aggregation = "Maximum" - operator = "GreaterThan" - threshold = 35 - divide_by_instance_count = false - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "4" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_lollipop_itn.id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 300 - divide_by_instance_count = true - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_lollipop_itn.app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 15 - divide_by_instance_count = false - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT2M" - } - } - } + tags = var.tags } # --------------------------------- diff --git a/src/domains/citizen-auth-app/07_function_fast_login.tf b/src/domains/citizen-auth-app/07_function_fast_login.tf index 591ccc6f7..596a306d0 100644 --- a/src/domains/citizen-auth-app/07_function_fast_login.tf +++ b/src/domains/citizen-auth-app/07_function_fast_login.tf @@ -201,36 +201,10 @@ module "function_fast_login_itn_autoscale" { minutes = 59 } }, - low_load = { - name = "night" - minimum = 3 - default = 10 - start = { - hour = 23 - minutes = 00 - } - end = { - hour = 05 - minutes = 00 - } - }, normal_load = { minimum = 3 default = 10 }, - gate0 = { - name = "auth_gate0" - minimum = 20 - default = 10 - start = { - hour = 8 - minutes = 00 - } - end = { - hour = 23 - minutes = 30 - } - }, maximum = 30 } diff --git a/src/domains/citizen-auth-app/09_function_profile.tf b/src/domains/citizen-auth-app/09_function_profile.tf index a73bc327a..3dbf43706 100644 --- a/src/domains/citizen-auth-app/09_function_profile.tf +++ b/src/domains/citizen-auth-app/09_function_profile.tf @@ -220,12 +220,13 @@ module "function_profile_staging_slot" { count = var.function_profile_count source = "git::https://github.com/pagopa/terraform-azurerm-v3.git//function_app_slot?ref=v8.44.0" - name = "staging" - location = local.itn_location - resource_group_name = azurerm_resource_group.function_profile_rg[count.index].name - function_app_id = module.function_profile[count.index].id - app_service_plan_id = module.function_profile[count.index].app_service_plan_id - health_check_path = "/api/v1/info" + name = "staging" + location = local.itn_location + resource_group_name = azurerm_resource_group.function_profile_rg[count.index].name + function_app_id = module.function_profile[count.index].id + app_service_plan_id = module.function_profile[count.index].app_service_plan_id + health_check_path = "/api/v1/info" + health_check_maxpingfailures = 2 storage_account_name = module.function_profile[count.index].storage_account.name storage_account_access_key = module.function_profile[count.index].storage_account.primary_access_key @@ -273,21 +274,7 @@ resource "azurerm_monitor_autoscale_setting" "function_profile" { capacity = { default = 10 - minimum = 5 - maximum = 30 - } - }, - { - name = "{\"name\":\"default\",\"for\":\"night\"}", - - recurrence = { - hours = 5 - minutes = 0 - } - - capacity = { - default = 10 - minimum = 5 + minimum = 3 maximum = 30 } }, @@ -301,23 +288,9 @@ resource "azurerm_monitor_autoscale_setting" "function_profile" { capacity = { default = 10 - minimum = 5 + minimum = 4 maximum = 30 } - }, - { - name = "night" - - recurrence = { - hours = 23 - minutes = 0 - } - - capacity = { - default = 10 - minimum = 5 - maximum = 30 - }, } ] iterator = profile_info @@ -442,7 +415,7 @@ resource "azurerm_monitor_autoscale_setting" "function_profile" { } profile { - name = "auth_gate0" + name = "wallet_gate0" fixed_date { timezone = "W. Europe Standard Time" @@ -451,8 +424,8 @@ resource "azurerm_monitor_autoscale_setting" "function_profile" { } capacity { - default = 10 - minimum = 20 + default = 20 + minimum = 15 maximum = 30 } diff --git a/src/domains/citizen-auth-app/09_function_profile_async.tf b/src/domains/citizen-auth-app/09_function_profile_async.tf index b7cf337b2..861943d1c 100644 --- a/src/domains/citizen-auth-app/09_function_profile_async.tf +++ b/src/domains/citizen-auth-app/09_function_profile_async.tf @@ -206,110 +206,6 @@ resource "azurerm_monitor_autoscale_setting" "function_profile_async" { } } } - - profile { - name = "auth_gate0" - - capacity { - default = 10 - minimum = 20 - maximum = 30 - } - - fixed_date { - timezone = "W. Europe Standard Time" - start = "2024-10-15T08:00:00.000Z" - end = "2024-10-15T23:30:00.000Z" - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_profile_async.id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT1M" - time_aggregation = "Average" - operator = "GreaterThan" - threshold = 3000 - divide_by_instance_count = false - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "2" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_profile_async.app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT1M" - time_aggregation = "Average" - operator = "GreaterThan" - threshold = 45 - divide_by_instance_count = false - } - - scale_action { - direction = "Increase" - type = "ChangeCount" - value = "2" - cooldown = "PT1M" - } - } - - rule { - metric_trigger { - metric_name = "Requests" - metric_resource_id = module.function_profile_async.id - metric_namespace = "microsoft.web/sites" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 2000 - divide_by_instance_count = false - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT20M" - } - } - - rule { - metric_trigger { - metric_name = "CpuPercentage" - metric_resource_id = module.function_profile_async.app_service_plan_id - metric_namespace = "microsoft.web/serverfarms" - time_grain = "PT1M" - statistic = "Average" - time_window = "PT5M" - time_aggregation = "Average" - operator = "LessThan" - threshold = 30 - divide_by_instance_count = false - } - - scale_action { - direction = "Decrease" - type = "ChangeCount" - value = "1" - cooldown = "PT20M" - } - } - } } ## Alerts