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 | AzureRM version |
---|---|---|
>= 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 |
This module is optimized to work with the 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.
module "logs" {
source = "claranet/run/azurerm//modules/logs"
version = "x.x.x"
client_name = var.client_name
environment = var.environment
stack = var.stack
location = module.azure_region.location
location_short = module.azure_region.location_short
resource_group_name = module.rg.resource_group_name
}
module "lb" {
source = "claranet/lb/azurerm"
version = "x.x.x"
client_name = var.client_name
environment = var.environment
location = module.azure_region.location
location_short = module.azure_region.location_short
stack = var.stack
resource_group_name = module.rg.resource_group_name
allocate_public_ip = true
enable_nat = true
}
module "eventhub" {
source = "git::https://github.com/tothenew/terraform-azure-eventhub.git"
location = module.azure_region.location
location_short = module.azure_region.location_short
client_name = var.client_name
environment = var.environment
stack = var.stack
resource_group_name = module.rg.resource_group_name
create_dedicated_cluster = false
namespace_parameters = {
sku = "Standard"
capacity = 2
}
hubs_parameters = {
logs = {
custom_name = "main-logs-hub"
partition_count = 2
}
}
logs_destinations_ids = []
}
module "diagnostic_settings" {
source = "git::https://github.com/tothenew/terraform-azure-diagnostics.git"
resource_id = module.lb.lb_id
logs_destinations_ids = [
module.logs.logs_storage_account_id,
module.logs.log_analytics_workspace_id,
format("%s|%s", module.eventhub.namespace_send_authorization_rule.id, module.eventhub.eventhubs["logs"].name),
]
log_analytics_destination_type = "Dedicated"
}
Name | Version |
---|---|
azurecaf | ~> 1.2, >= 1.2.22 |
azurerm | ~> 3.39 |
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 |
"AzureDiagnostics" |
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 destination, you must provide a formatted 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. |
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 |
use_caf_naming | Use the Azure CAF naming provider to generate default resource name. custom_name override this if set. Legacy default name is used if this is set to false . |
bool |
true |
no |
Name | Description |
---|---|
diagnostic_settings_id | ID of the Diagnostic Settings. |
Module managed by TO THE NEW Pvt. Ltd.
Apache 2 Licensed. See LICENSE for full details.
Azure Diagnostic settings documentation: docs.microsoft.com/en-us/azure/azure-monitor/essentials/diagnostic-settings