Easy Way to Build an Azure Log Analytics Query


By:   |   Updated: 2018-03-20   |   Comments   |   Related: More > Azure


Problem

You want an easy way to query your Microsoft Azure Log Analytics data in the OMS Log Search.  Check out this tip to learn how.

Solution

In order to easily query the data, we will be using the ability to add filters from the left side of the Log Search window that appears after you run even a basic query.

Note: It’s assumed you’re using the new and not the legacy Log Analytics query language.

Login to Azure Portal

Let’s get started by logging in to the Azure Portal. Next, search for Log Analytics.

Azure Portal Dashboard

Choose your Log Analytics workspace if prompted.

Log Analytics Blade

Click on OMS Portal to open the portal in another tab.

Log Analytics Workspace Blade - Description: This is where you can open the OMS Portal.


Click on the Log Search button on the left.

OMS Portal - Description: Open Log Search window here.

Building Azure Log Analytics Query

And we’re ready to get down to building a query. For our example we’ll start by searching the performance logs to return all the performance records for the default period.

  • Type Perf (case sensitive) in the query window
  • Click on the Search button
Initial Log Search results - Description: Start filtering here.

Now you can:

  • Choose the timeframe you want data from
  • Select machine you want data from
  • Choose performance counter you want
Filter Results

After we’ve defined our filter we can:

  • Run the query
  • Export results to a .csv
  • Generate a Power BI query
  • Create a Log Analytics Alert
  • Save the query
 Output Options - Description: You can output your results to .csv or PowerBI, save search and / or create an alert.

Let’s look at each option.

Run the Query

Running the query generates a list where you can view details on each entry. Click table for a table view.

Filtered Output List (default)
Filtered Output Table

Export Results

Export up to 5000 rows of the results to a .csv file.

Export to .csv

Generate a Power BI query

Generate a Power BI query to a .txt file.

Generate Power BI Query
Power BI Query

Create a Log Analytics Alert

Create an alert - https://www.mssqltips.com/sqlservertip/5272/create-an-alert-in-microsoft-azure-log-analytics/.

Alert

Save your query

Follow below to save the query.

Save Query

More Options

  • Add it to your Favorites
Add to Favorites
  • Search History
Search History
  • Open results in Advanced Analytics
Results in Advanced Analytics
Advanced Analytics
Next Steps

Here are some links with more information:



Last Updated: 2018-03-20


get scripts

next tip button



About the author
MSSQLTips author Joe Gavin Joe Gavin is from Greater Boston. He has held many roles in IT and is currently a SQL Server Database Administrator.

View all my tips
Related Resources





Comments For This Article





download





Recommended Reading

Adding Users to Azure SQL Databases

Connect to On-premises Data in Azure Data Factory with the Self-hosted Integration Runtime - Part 1

Process Blob Files Automatically using an Azure Function with Blob Trigger

Using Azure Blueprints to deploy Azure SQL Server and Database with Key Vault Secrets

Managing Azure Blueprints with PowerShell








get free sql tips
agree to terms


Learn more about SQL Server tools