Skip to content

Commit 0fe8279

Browse files
authored
Merge pull request #509 from NHSDigital/feat/DTOSS-11103-Azure-monitor-infrastructure-metrics-for-container-app-jobs
[DTOSS-11103] Add new alerting on container app jobs
2 parents 2b45e42 + 8f6219c commit 0fe8279

7 files changed

Lines changed: 18 additions & 6 deletions

File tree

infrastructure/environments/review/variables.tfvars

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ vnet_address_space = "10.142.0.0/16"
1010
deploy_database_as_container = true
1111
seed_demo_data = true
1212
nhs_notify_api_message_batch_url = "https://int.api.service.nhs.uk/comms/v1/message-batches"
13-
enable_alerting = true

infrastructure/modules/container-apps/jobs.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ module "db_setup" {
8888
local.common_env,
8989
var.deploy_database_as_container ? local.container_db_env : local.azure_db_env
9090
)
91+
92+
# alerts
93+
action_group_id = var.action_group_id
94+
enable_alerting = var.enable_alerting
95+
log_analytics_workspace_id = var.log_analytics_workspace_id
96+
9197
depends_on = [
9298
module.queue_storage_role_assignment,
9399
module.blob_storage_role_assignment
@@ -130,6 +136,12 @@ module "scheduled_jobs" {
130136
var.deploy_database_as_container ? local.container_db_env : local.azure_db_env
131137
)
132138

139+
140+
# alerts
141+
action_group_id = var.action_group_id
142+
enable_alerting = var.enable_alerting
143+
log_analytics_workspace_id = var.log_analytics_workspace_id
144+
133145
# Ensure RBAC role assignments are created before the job definition finalizes
134146
depends_on = [
135147
module.blob_storage_role_assignment,

infrastructure/modules/container-apps/postgres.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module "postgres" {
2525
admin_identities = [module.db_connect_identity[0]]
2626

2727
# Diagnostic Settings
28-
log_analytics_workspace_id = var.log_analytics_workspace_audit_id
28+
log_analytics_workspace_id = var.log_analytics_workspace_id
2929
monitor_diagnostic_setting_postgresql_server_enabled_logs = ["PostgreSQLLogs", "PostgreSQLFlexSessions", "PostgreSQLFlexQueryStoreRuntime", "PostgreSQLFlexQueryStoreWaitStats", "PostgreSQLFlexTableStats", "PostgreSQLFlexDatabaseXacts"]
3030
monitor_diagnostic_setting_postgresql_server_metrics = ["AllMetrics"]
3131

infrastructure/modules/container-apps/storage.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module "storage" {
1717

1818
containers = local.storage_containers
1919
location = var.region
20-
log_analytics_workspace_id = var.log_analytics_workspace_audit_id
20+
log_analytics_workspace_id = var.log_analytics_workspace_id
2121
# log_analytics_workspace_id = module.log_analytics_workspace_audit.id
2222

2323
monitor_diagnostic_setting_storage_account_enabled_logs = ["StorageWrite", "StorageRead", "StorageDelete"]

infrastructure/modules/container-apps/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ variable "hub" {
7373
type = string
7474
}
7575

76-
variable "log_analytics_workspace_audit_id" {
76+
variable "log_analytics_workspace_id" {
7777
description = "Log analytics workspace audit ID"
7878
type = string
7979
}
8080

81+
8182
variable "deploy_database_as_container" {
8283
description = "Whether to deploy the database as a container or as an Azure postgres flexible server."
8384
type = bool

infrastructure/modules/infra/output.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ output "vnet_name" {
1010
value = module.main_vnet.name
1111
}
1212

13-
output "log_analytics_workspace_audit_id" {
13+
output "log_analytics_workspace_id" {
1414
value = module.log_analytics_workspace_audit.id
1515
}
1616

infrastructure/terraform/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ module "container-apps" {
5555
fetch_secrets_from_app_key_vault = var.fetch_secrets_from_app_key_vault
5656
front_door_profile = var.front_door_profile
5757
hub = var.hub
58-
log_analytics_workspace_audit_id = var.deploy_infra ? module.infra[0].log_analytics_workspace_audit_id : data.azurerm_log_analytics_workspace.audit[0].id
58+
log_analytics_workspace_id = var.deploy_infra ? module.infra[0].log_analytics_workspace_id : data.azurerm_log_analytics_workspace.audit[0].id
5959
postgres_backup_retention_days = var.postgres_backup_retention_days
6060
postgres_geo_redundant_backup_enabled = var.postgres_geo_redundant_backup_enabled
6161
postgres_sku_name = var.postgres_sku_name

0 commit comments

Comments
 (0)