SOLVED

KQL query to check the v-net peering status

%3CLINGO-SUB%20id%3D%22lingo-sub-1504183%22%20slang%3D%22en-US%22%3EKQL%20query%20to%20check%20the%20v-net%20peering%20status%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1504183%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Friends%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Ei%20am%20surprised%20there%20is%20no%20way%20to%20monitor%20the%20status%20of%20vnet%20peering%20using%20azure%20monitor.%3C%2FP%3E%3CP%3ECan%20any%20one%20help%20to%20find%26nbsp%3B%20KQL%20query%20to%20check%20the%20v-net%20peering%20status%20.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1504183%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1505497%22%20slang%3D%22en-US%22%3ERe%3A%20KQL%20query%20to%20check%20the%20v-net%20peering%20status%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1505497%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F715795%22%20target%3D%22_blank%22%3E%40Srini1987%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EVNet%20peering%20is%20a%20SDN%20solution%20for%20connecting%20two%20different%20VNets.%20You%20don't%20have%20devices%2Fappliances%20implementing%20the%20peering.%20Having%20Azure%20Monitor%20metrics%20for%20peering%20status%20would%20be%20almost%20similar%20to%20having%20metrics%20for%20subnet-to-subnet%20connectivity.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20you%20can%20implement%20yourself%20a%20Connection%20monitor%2C%20with%20two%20VM%20endpoints%20(one%20in%20each%20side%20of%20the%20peering).%20See%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fnetwork-watcher%2Fconnection-monitor-preview%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Emore%20info%20on%20that%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1556106%22%20slang%3D%22en-US%22%3ERe%3A%20KQL%20query%20to%20check%20the%20v-net%20peering%20status%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1556106%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F715795%22%20target%3D%22_blank%22%3E%40Srini1987%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20could%20try%20using%20Azure%20Resource%20Graph%20(also%20KQL-based)%20and%20this%20query%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3Eresources%0A%7C%20where%20type%20%3D~%20'Microsoft.network%2FvirtualNetworks'%0A%7C%20extend%20peerings%3Darray_length(properties.virtualNetworkPeerings)%0A%7C%20mv-expand%20peering%3Dproperties.virtualNetworkPeerings%0A%7C%20where%20isnotempty(peerings)%0A%7C%20project%20networkId%20%3D%20id%2C%20VNetName%20%3D%20name%2C%20peeringState%3Dtostring(peering.properties.peeringState)%2C%20peering%3C%2FCODE%3E%3C%2FPRE%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EThe%20peeringState%20column%20should%20show%20you%20the%20status.%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hi Friends,

 

i am surprised there is no way to monitor the status of vnet peering using azure monitor.

Can any one help to find  KQL query to check the v-net peering status .

2 Replies

@Srini1987 

 

VNet peering is a SDN solution for connecting two different VNets. You don't have devices/appliances implementing the peering. Having Azure Monitor metrics for peering status would be almost similar to having metrics for subnet-to-subnet connectivity.

 

However, you can implement yourself a Connection monitor, with two VM endpoints (one in each side of the peering). See more info on that.

Best Response confirmed by Srini1987 (Occasional Contributor)
Solution

Hi @Srini1987 ,

 

You could try using Azure Resource Graph (also KQL-based) and this query:

 

resources
| where type =~ 'Microsoft.network/virtualNetworks'
| extend peerings=array_length(properties.virtualNetworkPeerings)
| mv-expand peering=properties.virtualNetworkPeerings
| where isnotempty(peerings)
| project networkId = id, VNetName = name, peeringState=tostring(peering.properties.peeringState), peering
 
The peeringState column should show you the status.