microsoft / Application-Insights-Workbooks

Templates for Azure Monitor Workbooks
MIT License
562 stars 462 forks source link

All the VMs in the VNET are shown as backend member of IP-based backend pool #2492

Open shiniizuka opened 11 months ago

shiniizuka commented 11 months ago

This is for: https://github.com/microsoft/Application-Insights-Workbooks/blob/master/Workbooks/Network%20Insights/LoadBalancerWorkbooks/NetworkInsights-LoadBalancerMetrics-Minified/NetworkInsights-LoadBalancerMetrics-Minified.workbook

SYMPTOM: When the backend pool is IP-based backend pool, not only the backend VMs but also all the VMs in the same VNET are shown as backend members.

CAUSE: This seems to be the current limitation caused by current query:

Resources
| where type =~ "microsoft.network/loadbalancers" and id =~ '/subscriptions/de184a51-1f30-4b7a-82a8-3114064d716e/resourceGroups/DC_group/providers/Microsoft.Network/loadBalancers/LBTest'
| mv-expand BackendAddressPool = parse_json(properties).backendAddressPools
| mv-expand loadBalancerBackendAddresses = parse_json(BackendAddressPool).properties.loadBalancerBackendAddresses
| mv-expand virtualNetwork = parse_json(loadBalancerBackendAddresses).properties.virtualNetwork
| project virtualNetworkId = tolower(virtualNetwork.id)
| join (
    resources
    | where type == "microsoft.network/virtualnetworks"
    | mv-expand subnets = parse_json(properties).subnets
    | mv-expand ipconfigs = parse_json(subnets).properties.ipConfigurations
    | project virtualNetworkId = tolower(id), NICId = tolower(substring(ipconfigs.id, 0, indexof(ipconfigs.id, "/ipConfigurations/")))
) on virtualNetworkId
| where NICId contains "microsoft.network/networkInterfaces"
| join kind=inner
(
    resources
    | where type == "microsoft.network/networkinterfaces"
    | project NICId = tolower(id), BackendVM = properties.virtualMachine.id
) on NICId
| where isnotempty(BackendVM)
| project tolower(BackendVM), selected = true

It will be better if the query can be updatedto show actual backend members only.

gardnerjr commented 11 months ago

@snagpal99 it looks like you're the last one to modify this template, can you look at this?