diff --git a/infrastructure/modules/service-bus/main.tf b/infrastructure/modules/service-bus/main.tf
index a26cbd36..6c6b2d65 100644
--- a/infrastructure/modules/service-bus/main.tf
+++ b/infrastructure/modules/service-bus/main.tf
@@ -61,3 +61,15 @@ module "private_endpoint_service_bus_namespace" {
tags = var.tags
}
+
+module "diagnostic-settings" {
+ source = "../diagnostic-settings"
+
+ count = var.log_analytics_workspace_id != null ? 1 : 0
+
+ name = "${var.servicebus_namespace_name}-diagnostic-setting"
+ target_resource_id = azurerm_servicebus_namespace.this.id
+ log_analytics_workspace_id = var.log_analytics_workspace_id
+ enabled_metric = var.monitor_diagnostic_setting_servicebus_metrics
+ enabled_log = var.monitor_diagnostic_setting_servicebus_enabled_logs
+}
diff --git a/infrastructure/modules/service-bus/tfdocs.md b/infrastructure/modules/service-bus/tfdocs.md
index 4ea7a456..f572e5f6 100644
--- a/infrastructure/modules/service-bus/tfdocs.md
+++ b/infrastructure/modules/service-bus/tfdocs.md
@@ -52,6 +52,30 @@ Type: `string`
Default: `"uksouth"`
+### [log\_analytics\_workspace\_id](#input\_log\_analytics\_workspace\_id)
+
+Description: id of the log analytics workspace to send resource logging to via diagnostic settings. If omitted, Diagnostic Settings will not be enabled.
+
+Type: `string`
+
+Default: `null`
+
+### [monitor\_diagnostic\_setting\_servicebus\_enabled\_logs](#input\_monitor\_diagnostic\_setting\_servicebus\_enabled\_logs)
+
+Description: controls what logs will be enabled for the service bus
+
+Type: `list(string)`
+
+Default: `[]`
+
+### [monitor\_diagnostic\_setting\_servicebus\_metrics](#input\_monitor\_diagnostic\_setting\_servicebus\_metrics)
+
+Description: controls what metrics will be enabled for the service bus
+
+Type: `list(string)`
+
+Default: `[]`
+
### [partitioning\_enabled](#input\_partitioning\_enabled)
Description: Boolean flag which controls whether to enable the topic to be partitioned across multiple message brokers. Changing this forces a new resource to be created.
@@ -119,6 +143,12 @@ Default: `{}`
The following Modules are called:
+### [diagnostic-settings](#module\_diagnostic-settings)
+
+Source: ../diagnostic-settings
+
+Version:
+
### [private\_endpoint\_service\_bus\_namespace](#module\_private\_endpoint\_service\_bus\_namespace)
Source: ../private-endpoint
diff --git a/infrastructure/modules/service-bus/variables.tf b/infrastructure/modules/service-bus/variables.tf
index 4d8dee50..167fabc1 100644
--- a/infrastructure/modules/service-bus/variables.tf
+++ b/infrastructure/modules/service-bus/variables.tf
@@ -111,3 +111,21 @@ variable "private_endpoint_properties" {
error_message = "Both private_dns_zone_ids and private_endpoint_subnet_id must be provided if private_endpoint_enabled is true."
}
}
+
+variable "log_analytics_workspace_id" {
+ type = string
+ description = "id of the log analytics workspace to send resource logging to via diagnostic settings. If omitted, Diagnostic Settings will not be enabled."
+ default = null
+}
+
+variable "monitor_diagnostic_setting_servicebus_metrics" {
+ type = list(string)
+ description = "controls what metrics will be enabled for the service bus"
+ default = []
+}
+
+variable "monitor_diagnostic_setting_servicebus_enabled_logs" {
+ type = list(string)
+ description = "controls what logs will be enabled for the service bus"
+ default = []
+}