Home
%3CLINGO-SUB%20id%3D%22lingo-sub-841067%22%20slang%3D%22en-US%22%3EAzure%20Event%20Hub%20%7C%20Push%20Performance%20Counter%20logs%20from%20Azure%20Virtual%20Machine%20to%20Azure%20Event%20Hub%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-841067%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%3CU%3EUse%20Case%3A%20%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ETo%20push%20performance%20counter%20logs%20from%20Azure%20Windows%20Virtual%20Machine%20to%20Azure%20Event%20Hub.%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CU%3EPre-%20Requisites%20%3A%20%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3ETo%20achieve%20the%20above-said%20pipeline%2C%20this%20blog%20assumes%20that%20you%20have%20the%20following%20resources%20under%20your%20Azure%20subscription%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAzure%20Windows%20Virtual%20Machine%3C%2FLI%3E%0A%3CLI%3EAzure%20Storage%20Account%3C%2FLI%3E%0A%3CLI%3EAzure%20Event%20Hub%20Namespace%3C%2FLI%3E%0A%3CLI%3EAn%20Event%20Hub%20inside%20the%20namespace%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3E%3CU%3ESteps%20Taken%3A%3C%2FU%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EWe%20would%20be%20using%20a%20%3CSTRONG%3Ediagnostics.wadcfgx%3C%2FSTRONG%3Efile%20that%20would%20be%20used%20to%20push%20the%20logs%20from%20VM%20to%20the%20event%20hub%20entity.%20The%20steps%20to%20be%20taken%20are%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDownload%20the%20diagnostics.wadcfgx%20file%20from%20%3CA%20href%3D%22https%3A%2F%2Fdiaglogseh.blob.core.windows.net%2Fdiaglogseh%2Fdiagnostics.wadcfgx%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehere%3C%2FA%3Eand%20update%20the%20placeholders%20with%20details%20accordingly.%20The%20placeholders%20to%20be%20updated%20are%20%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26lt%3B%20Event%20hub%20namespace%26gt%3B%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CEVENT%20hub%3D%22%22%20entity%3D%22%22%3E%3C%2FEVENT%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSTORAGE%20account%3D%22%22%20name%3D%22%22%3E%3C%2FSTORAGE%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSUBSCRIPTION%20id%3D%22%22%3E%3C%2FSUBSCRIPTION%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CRESOURCE%20group%3D%22%22%20name%3D%22%22%3E%3C%2FRESOURCE%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CWINDOWS%20vm%3D%22%22%20name%3D%22%22%3E%3C%2FWINDOWS%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSTRONG%3E%26lt%3B%3C%2FSTRONG%3E%3CSTRONG%3EEvent%20hub%20SharedAccesskey%20name%26gt%3B%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CEVENT%20hub%3D%22%22%20sharedaccesskey%3D%22%22%20value%3D%22%22%3E%3C%2FEVENT%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3CSTORAGE%20account%3D%22%22%20key%3D%22%22%3E%3C%2FSTORAGE%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3EKeep%20the%20file%20name%20and%20extension%20as%20diagnostics.%3CU%3Ewadcfgx%3C%2FU%3Ewhile%20you%20save%20it.%20%3CSTRONG%3EPlease%20make%20sure%20that%20you%20pass%20the%20event%20hub%20namespace%20level%20connection%20string%20and%20not%20the%20instance%20one%20for%20this%20setup.%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20the%20file%20is%20saved%2C%20open%20the%20PowerShell%20on%20the%20local%20machine%20and%20connect%20to%20the%20Azure%20account%20using%20the%20command%20%3CSTRONG%3EConnect-AzAccount%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3EAfter%20you%20have%20logged%20in%2C%20run%20this%20PowerShell%20script%20to%20push%20the%20extension%20to%20the%20VM.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff0000%22%3ESelect-AzSubscription%20-SubscriptionId%209cee3d8e-05bb-xxxx-xxxx-xxxxxxxxxx%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff0000%22%3E%24rgName%20%3D%20%22%3CRESOURCE%20group%3D%22%22%20name%3D%22%22%3E%22%3C%2FRESOURCE%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff0000%22%3E%24vmName%20%3D%20%22%3CWINDOWS%20vm%3D%22%22%20name%3D%22%22%3E%22%3C%2FWINDOWS%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff0000%22%3E%24diagnosticsconfig_path%20%3D%20%22%3CLOCAL%20path%3D%22%22%20where%3D%22%22%20the%3D%22%22%20.wadcfgx%3D%22%22%20file%3D%22%22%20is%3D%22%22%20stored%3D%22%22%3E%22%3C%2FLOCAL%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff0000%22%3E%24diagnosticsstorage_name%20%3D%20%22%3CSTORAGE%20account%3D%22%22%20name%3D%22%22%3E%22%3C%2FSTORAGE%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff0000%22%3E%24diagnosticsstorage_key%20%3D%20%22%20%3CSTORAGE%20account%3D%22%22%20key%3D%22%22%3E%22%3C%2FSTORAGE%3E%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20color%3D%22%23ff0000%22%3ESet-AzVMDiagnosticsExtension%20-ResourceGroupName%20%24rgName%20-VMName%20%24vmName%20-DiagnosticsConfigurationPath%20%24diagnosticsconfig_path%20-StorageAccountName%20%24diagnosticsstorage_name%20-StorageAccountKey%20%24diagnosticsstorage_key%3C%2FFONT%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20the%20operation%20has%20been%20successful%2C%20you%20would%20see%20a%20success%20output%20on%20the%20PowerShell%20console%20window.%20This%20means%20that%20the%20pipeline%20has%20been%20set-up%20and%20logs%20would%20be%20pushed%20from%20VM%20to%20the%20event%20hub.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELooking%20at%20the%20event%20hub%20metrics%20(messages%20section)%20from%20the%20portal%2C%20you%20would%20be%20able%20to%20confirm%20that%20there%20has%20been%20traffic%20traversing%20the%20event%20hub.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F128705i32E5B03DE8F42163%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22metrics.png%22%20title%3D%22metrics.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EEvent%20hub%20Metrics%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELooking%20into%20the%20data%20that%20has%20been%20pushed%20into%20the%20event%20hub%2C%20we%20can%20confirm%20the%20VM%20perf%20logs%20have%20been%20successfully%20pushed.%20Here%20is%20a%26nbsp%3B%20screenshot.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F128704i9ADAE51D16241610%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22event%20hub%20output.png%22%20title%3D%22event%20hub%20output.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EEvent%20hub%20output%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EHope%20this%20helps!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-841067%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Event%20Hub%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Eazure%20service%20bus%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E

Use Case:

To push performance counter logs from Azure Windows Virtual Machine to Azure Event Hub.

Pre- Requisites :

To achieve the above-said pipeline, this blog assumes that you have the following resources under your Azure subscription:

  • Azure Windows Virtual Machine
  • Azure Storage Account
  • Azure Event Hub Namespace
  • An Event Hub inside the namespace

Steps Taken:

We would be using a diagnostics.wadcfgx file that would be used to push the logs from VM to the event hub entity. The steps to be taken are:

 

Download the diagnostics.wadcfgx file from here and update the placeholders with details accordingly. The placeholders to be updated are :

 

  •         < Event hub namespace>
  •         <Event hub entity>
  •         <Storage account name>
  •         <Subscription ID>
  •         <Resource group Name>
  •         <Windows VM name>
  •         < Event hub SharedAccesskey name>
  •         <Event hub SharedAccesskey value>
  •         <Storage account key>

Keep the file name and extension as diagnostics.wadcfgx while you save it. Please make sure that you pass the event hub namespace level connection string and not the instance one for this setup.

 

Once the file is saved, open the PowerShell on the local machine and connect to the Azure account using the command Connect-AzAccount

After you have logged in, run this PowerShell script to push the extension to the VM.

 

Select-AzSubscription -SubscriptionId 9cee3d8e-05bb-xxxx-xxxx-xxxxxxxxxx

$rgName = "<Resource Group Name>"

$vmName = "<Windows VM Name>"

$diagnosticsconfig_path = "<Local path where the .wadcfgx file is stored>"

$diagnosticsstorage_name = "<Storage Account Name>"

$diagnosticsstorage_key = " <Storage Account Key>"

 

Set-AzVMDiagnosticsExtension -ResourceGroupName $rgName -VMName $vmName -DiagnosticsConfigurationPath $diagnosticsconfig_path -StorageAccountName $diagnosticsstorage_name -StorageAccountKey $diagnosticsstorage_key

 

After the operation has been successful, you would see a success output on the PowerShell console window. This means that the pipeline has been set-up and logs would be pushed from VM to the event hub.

 

Looking at the event hub metrics (messages section) from the portal, you would be able to confirm that there has been traffic traversing the event hub.

 

metrics.pngEvent hub Metrics

 

Looking into the data that has been pushed into the event hub, we can confirm the VM perf logs have been successfully pushed. Here is a  screenshot.

 

event hub output.pngEvent hub output

Hope this helps!