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

CME-122: Database monitoring and alerting on RD repositories #992

Merged
merged 8 commits into from
Dec 9, 2024

Conversation

SammiChong
Copy link
Contributor

JIRA link (if applicable)

https://tools.hmcts.net/jira/browse/CME-247

Change description

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[ x] No

@hmcts-jenkins-j-to-z
Copy link
Contributor

hmcts-jenkins-j-to-z bot commented Dec 5, 2024

Plan Result (aat)

Plan: 4 to add, 0 to change, 0 to destroy.
  • Create
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_action_group.db-alerts-action-group[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_cpu[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_memory[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_storage_utilization[0]
Change Result (Click me)
  # module.db-rd-caseworker-ref-v16.azurerm_monitor_action_group.db-alerts-action-group[0] will be created
  + resource "azurerm_monitor_action_group" "db-alerts-action-group" {
      + enabled             = true
      + id                  = (known after apply)
      + location            = "global"
      + name                = "action_group-rd-caseworker-ref-api-postgres-db-v16-aat"
      + resource_group_name = "rd-caseworker-ref-api-postgres-db-v16-data-aat"
      + short_name          = "action_group"
      + tags                = {
          + "application"         = "reference-data"
          + "autoShutdown"        = "true"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "staging"
          + "managedBy"           = "Reference Data"
        }

      + email_receiver {
          + email_address           = (sensitive value)
          + name                    = "Email Receiver"
          + use_common_alert_schema = true
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_cpu[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_cpu" {
      + auto_mitigate            = true
      + description              = "Whenever the cpu utilization is greater than 5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_cpu_percent_rd-caseworker-ref-api-postgres-db-v16-aat"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-aat"
      + scopes                   = [
          + "/subscriptions/1c4f0704-a29e-403d-b719-b90c34ef14c9/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-aat/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-aat",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "autoShutdown"        = "true"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "staging"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "cpu_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 5
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_memory[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_memory" {
      + auto_mitigate            = true
      + description              = "Whenever the memory utilization is greater than 5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_memory_percent_rd-caseworker-ref-api-postgres-db-v16-aat"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-aat"
      + scopes                   = [
          + "/subscriptions/1c4f0704-a29e-403d-b719-b90c34ef14c9/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-aat/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-aat",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "autoShutdown"        = "true"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "staging"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "memory_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 5
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_storage_utilization[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_storage_utilization" {
      + auto_mitigate            = true
      + description              = "Whenever the storage utilization is greater than 0.5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_storage_utilization_rd-caseworker-ref-api-postgres-db-v16-aat"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-aat"
      + scopes                   = [
          + "/subscriptions/1c4f0704-a29e-403d-b719-b90c34ef14c9/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-aat/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-aat",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "autoShutdown"        = "true"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "staging"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "storage_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 0.5
        }
    }

Plan: 4 to add, 0 to change, 0 to destroy.

@hmcts-jenkins-j-to-z
Copy link
Contributor

hmcts-jenkins-j-to-z bot commented Dec 5, 2024

Plan Result (prod)

Plan: 4 to add, 0 to change, 0 to destroy.
  • Create
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_action_group.db-alerts-action-group[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_cpu[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_memory[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_storage_utilization[0]
Change Result (Click me)
  # module.db-rd-caseworker-ref-v16.azurerm_monitor_action_group.db-alerts-action-group[0] will be created
  + resource "azurerm_monitor_action_group" "db-alerts-action-group" {
      + enabled             = true
      + id                  = (known after apply)
      + location            = "global"
      + name                = "action_group-rd-caseworker-ref-api-postgres-db-v16-prod"
      + resource_group_name = "rd-caseworker-ref-api-postgres-db-v16-data-prod"
      + short_name          = "action_group"
      + tags                = {
          + "application"         = "reference-data"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "production"
          + "managedBy"           = "Reference Data"
        }

      + email_receiver {
          + email_address           = (sensitive value)
          + name                    = "Email Receiver"
          + use_common_alert_schema = true
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_cpu[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_cpu" {
      + auto_mitigate            = true
      + description              = "Whenever the cpu utilization is greater than 5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_cpu_percent_rd-caseworker-ref-api-postgres-db-v16-prod"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-prod"
      + scopes                   = [
          + "/subscriptions/8999dec3-0104-4a27-94ee-6588559729d1/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-prod/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-prod",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "production"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "cpu_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 5
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_memory[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_memory" {
      + auto_mitigate            = true
      + description              = "Whenever the memory utilization is greater than 5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_memory_percent_rd-caseworker-ref-api-postgres-db-v16-prod"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-prod"
      + scopes                   = [
          + "/subscriptions/8999dec3-0104-4a27-94ee-6588559729d1/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-prod/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-prod",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "production"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "memory_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 5
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_storage_utilization[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_storage_utilization" {
      + auto_mitigate            = true
      + description              = "Whenever the storage utilization is greater than 0.5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_storage_utilization_rd-caseworker-ref-api-postgres-db-v16-prod"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-prod"
      + scopes                   = [
          + "/subscriptions/8999dec3-0104-4a27-94ee-6588559729d1/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-prod/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-prod",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "production"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "storage_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 0.5
        }
    }

Plan: 4 to add, 0 to change, 0 to destroy.

@SammiChong SammiChong marked this pull request as ready for review December 5, 2024 15:22
lukasz-wolski
lukasz-wolski previously approved these changes Dec 5, 2024
@SammiChong
Copy link
Contributor Author

Adding low thresholds to test emails are sending.

AntonyLeons
AntonyLeons previously approved these changes Dec 6, 2024
Copy link
Contributor

@kiran-yenigala-hmcts kiran-yenigala-hmcts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please format the files properly

Copy link
Contributor

@kiran-yenigala-hmcts kiran-yenigala-hmcts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SammiChong SammiChong changed the base branch from master to ithc December 6, 2024 16:11
@hmcts-jenkins-j-to-z
Copy link
Contributor

Plan Result (ithc)

Plan: 4 to add, 0 to change, 0 to destroy.
  • Create
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_action_group.db-alerts-action-group[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_cpu[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_memory[0]
    • module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_storage_utilization[0]
Change Result (Click me)
  # module.db-rd-caseworker-ref-v16.azurerm_monitor_action_group.db-alerts-action-group[0] will be created
  + resource "azurerm_monitor_action_group" "db-alerts-action-group" {
      + enabled             = true
      + id                  = (known after apply)
      + location            = "global"
      + name                = "action_group-rd-caseworker-ref-api-postgres-db-v16-ithc"
      + resource_group_name = "rd-caseworker-ref-api-postgres-db-v16-data-ithc"
      + short_name          = "action_group"
      + tags                = {
          + "application"         = "reference-data"
          + "autoShutdown"        = "true"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "ithc"
          + "managedBy"           = "Reference Data"
        }

      + email_receiver {
          + email_address           = (sensitive value)
          + name                    = "Email Receiver"
          + use_common_alert_schema = true
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_cpu[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_cpu" {
      + auto_mitigate            = true
      + description              = "Whenever the cpu utilization is greater than 5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_cpu_percent_rd-caseworker-ref-api-postgres-db-v16-ithc"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-ithc"
      + scopes                   = [
          + "/subscriptions/7a4e3bd5-ae3a-4d0c-b441-2188fee3ff1c/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-ithc/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-ithc",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "autoShutdown"        = "true"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "ithc"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "cpu_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 5
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_memory[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_memory" {
      + auto_mitigate            = true
      + description              = "Whenever the memory utilization is greater than 5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_memory_percent_rd-caseworker-ref-api-postgres-db-v16-ithc"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-ithc"
      + scopes                   = [
          + "/subscriptions/7a4e3bd5-ae3a-4d0c-b441-2188fee3ff1c/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-ithc/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-ithc",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "autoShutdown"        = "true"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "ithc"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "memory_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 5
        }
    }

  # module.db-rd-caseworker-ref-v16.azurerm_monitor_metric_alert.db_alert_storage_utilization[0] will be created
  + resource "azurerm_monitor_metric_alert" "db_alert_storage_utilization" {
      + auto_mitigate            = true
      + description              = "Whenever the storage utilization is greater than 0.5%"
      + enabled                  = true
      + frequency                = "PT1H"
      + id                       = (known after apply)
      + name                     = "db_storage_utilization_rd-caseworker-ref-api-postgres-db-v16-ithc"
      + resource_group_name      = "rd-caseworker-ref-api-postgres-db-v16-data-ithc"
      + scopes                   = [
          + "/subscriptions/7a4e3bd5-ae3a-4d0c-b441-2188fee3ff1c/resourceGroups/rd-caseworker-ref-api-postgres-db-v16-data-ithc/providers/Microsoft.DBforPostgreSQL/flexibleServers/rd-caseworker-ref-api-postgres-db-v16-ithc",
        ]
      + severity                 = 1
      + tags                     = {
          + "application"         = "reference-data"
          + "autoShutdown"        = "true"
          + "builtFrom"           = "https://github.com/HMCTS/rd-caseworker-ref-api.git"
          + "businessArea"        = "CFT"
          + "contactSlackChannel" = "#ref-data-support"
          + "environment"         = "ithc"
          + "managedBy"           = "Reference Data"
        }
      + target_resource_location = (known after apply)
      + target_resource_type     = (known after apply)
      + window_size              = "P1D"

      + action {
          + action_group_id = (known after apply)
        }

      + criteria {
          + aggregation            = "Average"
          + metric_name            = "storage_percent"
          + metric_namespace       = "Microsoft.DBforPostgreSQL/flexibleServers"
          + operator               = "GreaterThan"
          + skip_metric_validation = false
          + threshold              = 0.5
        }
    }

Plan: 4 to add, 0 to change, 0 to destroy.

@SivaKanukolluQA SivaKanukolluQA merged commit fa12b23 into ithc Dec 9, 2024
6 checks passed
@SivaKanukolluQA SivaKanukolluQA deleted the CME-122 branch December 9, 2024 16:34
@SammiChong SammiChong restored the CME-122 branch December 10, 2024 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants