Skip to content

Terraform module to enable Diagnostics and Logs on Azure VM

License

Notifications You must be signed in to change notification settings

zfiel/terraform-azurerm-vm-logs

 
 

Repository files navigation

Azure VM Linux - Enable diagnostics logs

Changelog Notice Apache V2 License TF Registry

This feature enables Diagnostics VM extension for Linux VM. It allows you to push logs on an Azure Storage Account and to enable Logs Analytics dashboards.

Version compatibility

Module version Terraform version AzureRM version
>= 5.x.x 0.15.x & 1.0.x >= 2.0
>= 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

Usage

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.

module "azure-region" {
  source  = "claranet/regions/azurerm"
  version = "x.x.x"

  azure_region = var.azure_region
}

module "rg" {
  source  = "claranet/rg/azurerm"
  version = "x.x.x"

  location    = module.azure-region.location
  client_name = var.client_name
  environment = var.environment
  stack       = var.stack
}

module "run-common" {
  source = "..."

  [..]
}

module "vm-logs" {
  source  = "claranet/vm-logs/azurerm"
  version = "x.x.x"

  location       = module.azure-region.location
  location_short = module.azure-region.location_short
  client_name    = var.client_name
  environment    = var.environment
  stack          = var.stack

  vm_id = module.linux-vm.vm_id

  diagnostics_storage_account_name      = module.run-common.logs_storage_account_name
  diagnostics_storage_account_sas_token = module.run-common.logs_storage_account_sas_token["sastoken"]

  tags = {
    environment = var.environment
    stack       = var.stack
  }
}

Providers

Name Version
azurerm >= 2.0
template >= 2.0

Modules

No modules.

Resources

Name Type
azurerm_virtual_machine_extension.diagnostics resource
azurerm_virtual_machine_extension.requirements resource
template_file.diag_json_config data source

Inputs

Name Description Type Default Required
default_tags_enabled Option to enable or disable default tags bool true no
diagnostics_linux_extension_version Linux VM diagnostics extension version string "3.0" no
diagnostics_storage_account_name Azure Storage Account to use for logs and diagnostics string n/a yes
diagnostics_storage_account_sas_token Azure Storage Account SAS Token. An Account SAS token for Blob and Table services (ss='bt'), applicable to containers and objects (srt='co'), which grants add, create, list, update, and write permissions (sp='acluw'). Do not include the leading question-mark (?). string n/a yes
environment Project environment string n/a yes
stack Project stack name string n/a yes
syslog_log_level_config Syslog Event Configuration log level [Can be LOG_DEBUG, LOG_INFO, LOG_NOTICE, LOG_ERR, LOG_CRIT, LOG_ALERT, LOG_EMERG] string "LOG_ERR" no
tags Tags to assign on ressources map(string) {} no
vm_extension_custom_name Custom VM extension name. string null no
vm_extension_name_suffix Extension suffix name. string "linux-diagnostics" no
vm_id Azure Linux VM ID to enable Diagnostics string n/a yes

Outputs

No outputs.

Related documentation

Microsoft Azure documentation: Use Linux Diagnostic Extension to monitor metrics and logs.

Terraform resource documentation: terraform.io/docs/providers/azurerm/r/virtual_machine_extension.html.

About

Terraform module to enable Diagnostics and Logs on Azure VM

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • HCL 100.0%