This module is based on work from Innovation Norway.
This Terraform enables the Diagnostic Settings on a given Azure resource.
Module version | Terraform version | AzureRM version |
---|---|---|
>= 4.x.x | 0.13.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 |
You can use this module by including it this way:
data "azurerm_resources" "resources" {
...
}
resource "azurerm_storage_account" "logs" {
...
}
resource "azurerm_log_analytics_workspace" "logs" {
...
}
resource "azurerm_eventhub_namespace" "logs" {
...
}
resource "azurerm_eventhub" "logs" {
...
}
resource "azurerm_eventhub_authorization_rule" "logs" {
...
}
module "diagnostic-settings" {
for_each = data.azurerm_resources.resources
source = "claranet/diagnostic-settings/azurerm"
version = "x.x.x"
resource_id = each.value.id
logs_destinations_ids = [
azurerm_storage_account.logs.id,
azurerm_log_analytics_workspace.example.id,
azurerm_eventhub_authorization_rule.logs.id,
]
log_analytics_destination_type = "Dedicated"
}
Name | Description | Type | Default | Required |
---|---|---|---|---|
eventhub_name | Event Hub name if one of the destinations is an Event Hub. | string |
null |
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. This only includes Azure Data Factory | string |
"AzureDiagnostics" |
no |
log_categories | List of log categories. | 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. | list(string) |
n/a | yes |
metric_categories | List of metric categories. | list(string) |
null |
no |
name | The name of the diagnostic setting. | string |
"default" |
no |
resource_id | The ID of the resource on which activate the diagnostic settings. | string |
n/a | yes |
retention_days | The number of days to keep diagnostic logs. | number |
30 |
no |
Name | Description |
---|---|
diagnostic_settings_id | ID of the Diagnostic Settings. |
Terraform documentation: terraform.io/docs/providers/azurerm/r/monitor_diagnostic_setting.html