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