I provisioned DCR, Log Analytics, VM, AMA, and the rest with terraform.
But my issue is I enabled VMInsights but I'm not getting and data in my Log Analytics Workspace and the VM insights is showing no data, I checked the extension on the VM it's running, the DCR is properly associated with the VM, but I don't know why I'm not getting the logs in Azure Monitor.
Here is my Terraform code.
resource "azurerm_log_analytics_workspace" "log_ignition" {
name = "LOG-${local.resource_name_suffix}"
location = var.location
resource_group_name = local.resource_group_name
sku = "PerGB2018"
retention_in_days = var.log_retention_in_days
tags = local.common_tags
}
resource "azurerm_log_analytics_solution" "log_solution_ignition" {
solution_name = "SecurityCenterFree"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
workspace_resource_id = azurerm_log_analytics_workspace.log_ignition.id
workspace_name = azurerm_log_analytics_workspace.log_ignition.name
tags = local.common_tags
plan {
publisher = "Microsoft"
product = "OMSGallery/SecurityCenterFree"
}
}
resource "azurerm_virtual_machine_extension" "vm_ignition_extension" {
name = "AzureMonitorLinuxAgent"
virtual_machine_id = azurerm_linux_virtual_machine.vm_ignition.id
publisher = "Microsoft.Azure.Monitor"
type = "AzureMonitorLinuxAgent"
type_handler_version = "1.29"
auto_upgrade_minor_version = true
automatic_upgrade_enabled = true
tags = local.common_tags
}
resource "azurerm_monitor_data_collection_rule" "dcr_ignition" {
name = "DCR-${local.resource_name_suffix}"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
tags = local.common_tags
description = "Data collection rule for VM Insights."
destination{
log_analytics {
workspace_resource_id = azurerm_log_analytics_workspace.log_ignition.id
name = "VMInsightsPerf-Logs-Dest"
}
}
data_flow {
streams = ["Microsoft-InsightsMetrics"]
destinations = ["VMInsightsPerf-Logs-Dest"]
}
data_sources {
performance_counter {
streams = ["Microsoft-InsightsMetrics"]
sampling_frequency_in_seconds = 60
counter_specifiers = ["\\VmInsights\\DetailedMetrics"]
name = "VMInsightsPerfCounters"
}
}
depends_on = [ azurerm_log_analytics_solution.log_solution_ignition ]
}