Azure Event Hub | Push Performance Counter logs from Azure Virtual Machine to Azure Event Hub
Published Sep 06 2019 08:25 AM 4,048 Views

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.

 

Event hub MetricsEvent 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 outputEvent hub output

Hope this helps!

 

Version history
Last update:
‎Sep 15 2020 08:10 AM
Updated by: