This module is based on work from Innovation Norway.
This Terraform enables the Diagnostic Settings on a given Azure resource.
If you want to specify an Azure EventHub to send logs and metrics to in logs_destinations_ids,
you need to provide a formated string with both the EventHub Namespace authorization send ID
and the EventHub name (name of the queue to use in the Namespace) separated by the | character.
Please refer to the example below for a detailed implementation.
| Module version | Terraform version | OpenTofu version | AzureRM version |
|---|---|---|---|
| >= 8.x.x | Unverified | 1.8.x | >= 4.0 |
| >= 7.x.x | 1.3.x | >= 3.0 | |
| >= 6.x.x | 1.x | >= 3.0 | |
| >= 5.x.x | 0.15.x | >= 2.0 | |
| >= 4.x.x | 0.13.x / 0.14.x | >= 2.0 | |
| >= 3.x.x | 0.12.x | >= 2.0 | |
| >= 2.x.x | 0.12.x | < 2.0 | |
| < 2.x.x | 0.11.x | < 2.0 |
If you want to contribute to this repository, feel free to use our pre-commit git hook configuration which will help you automatically update and format some files for you by enforcing our Terraform code module best-practices.
More details are available in the CONTRIBUTING.md file.
This module is optimized to work with the Claranet terraform-wrapper tool
which set some terraform variables in the environment needed by this module.
More details about variables set by the terraform-wrapper available in the documentation.
resource "azurerm_lb" "lb" {
location = module.azure_region.location
name = "lb"
resource_group_name = module.rg.name
}
module "diagnostic_settings" {
source = "claranet/diagnostic-settings/azurerm"
version = "x.x.x"
resource_id = azurerm_lb.lb.id
logs_destinations_ids = [
azurerm_log_analytics_workspace.log_workspace.id
]
log_analytics_destination_type = "Dedicated"
}| Name | Version |
|---|---|
| azurecaf | >= 1.2.28 |
| azurerm | ~> 4.31 |
No modules.
| Name | Type |
|---|---|
| azurerm_monitor_diagnostic_setting.main | resource |
| azurecaf_name.diag | data source |
| azurerm_monitor_diagnostic_categories.main | data source |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| custom_name | Name of the diagnostic settings, generated if empty. | string |
"" |
no |
| excluded_log_categories | List of log categories to exclude. | list(string) |
[] |
no |
| log_analytics_destination_type | When set to 'Dedicated' logs sent to a Log Analytics workspace will go into resource specific tables, instead of the legacy AzureDiagnostics table. | string |
"Dedicated" |
no |
| log_categories | List of log categories. Defaults to all available. | list(string) |
null |
no |
| logs_destinations_ids | List of destination resources IDs for logs diagnostic destination. Can be Storage Account, Log Analytics Workspace and Event Hub. No more than one of each can be set.If you want to use Azure EventHub as a destination, you must provide a formatted string containing both the EventHub Namespace authorization send ID and the EventHub name (name of the queue to use in the Namespace) separated by the | character. |
list(string) |
n/a | yes |
| metric_categories | List of metric categories. Defaults to all available. | list(string) |
null |
no |
| name_prefix | Optional prefix for the generated name. | string |
"" |
no |
| name_suffix | Optional suffix for the generated name. | string |
"" |
no |
| resource_id | The ID of the resource on which activate the diagnostic settings. | string |
n/a | yes |
| Name | Description |
|---|---|
| id | ID of the Diagnostic Settings. |
| resource | Diagnostic settings resource output. |
Azure Diagnostic settings documentation: docs.microsoft.com/en-us/azure/azure-monitor/essentials/diagnostic-settings