Hi,
I just stumbled upon this post, and have a solution so thought I would share. This is fixed by adding the code block below to resource "azurerm_virtual_machine_extension" "dependency_agent":
settings = jsonencode({
enableAMA = true
})
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi, community,
I want to monitor a single Azure VM by using the new Azure Monitor Agent for migration sake testing. Another requirement is that service map and VM Insights are enabled.
I used the following terraform code to deploy the monitoring solution. The VM was also deployed via terraform and is up and running.
resource "azurerm_log_analytics_workspace" "this" {
name = "law-this-005"
location = azurerm_resource_group.this.location
resource_group_name = azurerm_resource_group.this.name
sku = "PerGB2018"
retention_in_days = "31"
}
resource "azurerm_virtual_machine_extension" "dependency_agent" {
name = "DependencyAgentWindows"
virtual_machine_id = azurerm_windows_virtual_machine.this.id
publisher = "Microsoft.Azure.Monitoring.DependencyAgent"
type = "DependencyAgentWindows"
type_handler_version = "9.10"
automatic_upgrade_enabled = true
auto_upgrade_minor_version = true
}
resource "azurerm_virtual_machine_extension" "azure_monitor_agent" {
depends_on = [azurerm_virtual_machine_extension.dependency_agent]
name = "AzureMonitorWindowsAgent"
virtual_machine_id = azurerm_windows_virtual_machine.this.id
publisher = "Microsoft.Azure.Monitor"
type = "AzureMonitorWindowsAgent"
type_handler_version = "1.9"
automatic_upgrade_enabled = true
auto_upgrade_minor_version = true
}
resource "azapi_resource" "data_collection_rule" {
depends_on = [azurerm_virtual_machine_extension.azure_monitor_agent]
type = "Microsoft.Insights/dataCollectionRules@2021-09-01-preview"
name = "MSVMI-vminsights"
location = azurerm_resource_group.this.location
parent_id = azurerm_resource_group.this.id
body = jsonencode({
properties = {
dataFlows = [
{
streams = [
"Microsoft-InsightsMetrics"
],
destinations = [
"VMInsightsPerf-Logs-Dest"
]
},
{
streams = [
"Microsoft-ServiceMap"
],
destinations = [
"VMInsightsPerf-Logs-Dest"
]
}
]
dataSources = {
performanceCounters = [
{
streams = [
"Microsoft-InsightsMetrics"
]
samplingFrequencyInSeconds = 60
counterSpecifiers = [
"\\VmInsights\\DetailedMetrics"
]
name = "VMInsightsPerfCounters"
}
]
extensions = [
{
streams = [
"Microsoft-ServiceMap"
]
extensionName = "DependencyAgent"
extensionSettings = {}
name = "DependencyAgentDataSource"
}
]
}
description = "Data collection rule for VM Insights."
destinations = {
logAnalytics = [
{
name = "VMInsightsPerf-Logs-Dest"
workspaceResourceId = azurerm_log_analytics_workspace.this.id
}
]
}
}
kind = "Windows"
})
}
resource "azurerm_monitor_data_collection_rule_association" "msvmi" {
name = "VMInsights-Association"
target_resource_id = azurerm_windows_virtual_machine.this.id
data_collection_rule_id = azapi_resource.data_collection_rule.id
}
As I can see in the Portal, the required extensions (Azure Monitor Agent + Dependency Agent) are installed successfully:
The performance metrics in the Azure Monitor - VM Insights section are present:
When I check the Map section, I get the following error message:
==> I expect I can see the Dependency data at this point.
The Data Collection Rule is correctly associated with the VM:
Furthermore, Azure Monitor Agent Heartbeats are logged inside the Log Analytics Workspace.
Is there anything I am not aware of?
I understood the documentation as follows:
I also got from the documentation that I do not need to configure the Agent itself regarding auth due it will use the System-assigned Managed Identity of the VM (User-assigned Identity is not used). Furthermore, Log Analytics Solutions for VM Insights is unnecessary, so I didn't deploy any.
Appreciate any help!
Hi,
I just stumbled upon this post, and have a solution so thought I would share. This is fixed by adding the code block below to resource "azurerm_virtual_machine_extension" "dependency_agent":
settings = jsonencode({
enableAMA = true
})