Easy Way to Build an Azure Log Analytics Query

By:   |   Updated: 2018-03-20   |   Comments   |   Related: > 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:



sql server categories

sql server webinars

subscribe to mssqltips

sql server tutorials

sql server white papers

next tip



About the author
MSSQLTips author Joe Gavin Joe Gavin is from the Greater Boston area. He started working with SQL Server and Sybase in 1998 in the financial services industry and has been a SQL Server Database Administrator for a dairy cooperative since 2011. He graduated from Northeastern University in Boston with a Bachelor of Science in Engineering Technology (BSET) degree in Computer Technology. Joe has spoken at the Boston and Providence SQL Saturday events.

This author pledges the content of this article is based on professional experience and not AI generated.

View all my tips


Article Last Updated: 2018-03-20

Comments For This Article

















get free sql tips
agree to terms