Skip to content

Commit f2a8a6a

Browse files
authored
Merge pull request #286203 from kainawroth/kainawroth-tutorial-2
Updating Log Analytics tutorial doc [from PR #285439]
2 parents 8085420 + c488f8a commit f2a8a6a

20 files changed

+35
-17
lines changed

articles/azure-monitor/logs/log-analytics-tutorial.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ ms.topic: tutorial
55
author: guywild
66
ms.author: guywild
77
ms.reviewer: roygal
8-
ms.date: 10/31/2023
8+
ms.date: 09/05/2024
99

1010
---
1111

1212
# Log Analytics tutorial
1313

1414
Log Analytics is a tool in the Azure portal to edit and run log queries from data collected by Azure Monitor logs and interactively analyze their results. You can use Log Analytics queries to retrieve records that match particular criteria, identify trends, analyze patterns, and provide various insights into your data.
1515

16-
This tutorial walks you through the Log Analytics interface, gets you started with some basic queries, and shows you how you can work with the results. You'll learn how to:
16+
This tutorial walks you through the Log Analytics interface, gets you started with some basic queries, and shows you how you can work with the results. You learn how to:
1717

1818
> [!div class="checklist"]
1919
> * Understand the log data schema.
@@ -23,17 +23,20 @@ This tutorial walks you through the Log Analytics interface, gets you started wi
2323
> * Load, export, and copy queries and results.
2424
2525
> [!IMPORTANT]
26-
> In this tutorial, you'll use Log Analytics features to build one query and use another example query. When you're ready to learn the syntax of queries and start directly editing the query itself, read the [Kusto Query Language tutorial](/azure/data-explorer/kusto/query/tutorial?pivots=azuremonitor). That tutorial walks you through example queries that you can edit and run in Log Analytics. It uses several of the features that you'll learn in this tutorial.
26+
> In this tutorial, you use Log Analytics features to build one query and use another example query. When you're ready to learn the syntax of queries and start directly editing the query itself, read the [Kusto Query Language tutorial](/azure/data-explorer/kusto/query/tutorial?pivots=azuremonitor). That tutorial walks you through example queries that you can edit and run in Log Analytics. It uses several of the features that you learn in this tutorial.
2727
2828
## Prerequisites
2929

3030
This tutorial uses the [Log Analytics demo environment](https://portal.azure.com/#blade/Microsoft_Azure_Monitoring_Logs/DemoLogsBlade), which includes plenty of sample data that supports the sample queries. You can also use your own Azure subscription, but you might not have data in the same tables.
3131

32+
> [!NOTE]
33+
> Log Analytics has two modes - Simple and KQL. *This tutorial walks you through KQL mode.* For information on Simple mode, see [Analyze data using Log Analytics Simple mode (Preview)](log-analytics-simple-mode.md).
34+
3235
## Open Log Analytics
3336

3437
Open the [Log Analytics demo environment](https://portal.azure.com/#blade/Microsoft_Azure_Monitoring_Logs/DemoLogsBlade), or select **Logs** from the Azure Monitor menu in your subscription. This step sets the initial scope to a Log Analytics workspace so that your query selects from all data in that workspace. If you select **Logs** from an Azure resource's menu, the scope is set to only records from that resource. For details about the scope, see [Log query scope](./scope.md).
3538

36-
You can view the scope in the upper-left corner of the screen. If you're using your own environment, you'll see an option to select a different scope. This option isn't available in the demo environment.
39+
You can view the scope in the upper-left corner of the Logs experience, below the name of your active query tab. If you're using your own environment, you see an option to select a different scope. This option isn't available in the demo environment.
3740

3841
:::image type="content" source="media/log-analytics-tutorial/log-analytics-query-scope.png" alt-text="Screenshot that shows the Log Analytics scope for the demo." lightbox="media/log-analytics-tutorial/log-analytics-query-scope.png":::
3942

@@ -45,19 +48,21 @@ Expand the **Log Management** solution and locate the **AppRequests** table. You
4548

4649
:::image type="content" source="media/log-analytics-tutorial/table-details.png" alt-text="Screenshot that shows the Tables view." lightbox="media/log-analytics-tutorial/table-details.png":::
4750

48-
Select the link below **Useful links** to go to the table reference that documents each table and its columns. Select **Preview data** to have a quick look at a few recent records in the table. This preview can be useful to ensure that this is the data that you're expecting before you run a query with it.
51+
* Select the link below **Useful links** (in this example [AppRequests](/azure/azure-monitor/reference/tables/AppRequests)) to go to the table reference that documents each table and its columns.
52+
53+
* Select **Preview data** to have a quick look at a few recent records in the table. This preview can be useful to ensure it's the data you're expecting before you run a query with it.
4954

5055
:::image type="content" source="media/log-analytics-tutorial/preview-data.png" alt-text="Screenshot that shows preview data for the AppRequests table." lightbox="media/log-analytics-tutorial/preview-data.png":::
5156

5257
## Write a query
5358

54-
Let's write a query by using the **AppRequests** table. Double-click its name to add it to the query window. You can also type directly in the window. You can even get IntelliSense that will help complete the names of tables in the current scope and Kusto Query Language (KQL) commands.
59+
Let's write a query by using the **AppRequests** table. Double-click its name or hover over it and click on **Use in editor** to add it to the query window. You can also type directly in the window. You can even get IntelliSense which helps completing the names of tables in the current scope and Kusto Query Language (KQL) commands.
5560

5661
This is the simplest query that we can write. It just returns all the records in a table. Run it by selecting the **Run** button or by selecting **Shift+Enter** with the cursor positioned anywhere in the query text.
5762

5863
:::image type="content" source="media/log-analytics-tutorial/query-results.png" alt-text="Screenshot that shows query results." lightbox="media/log-analytics-tutorial/query-results.png":::
5964

60-
You can see that we do have results. The number of records that the query has returned appears in the lower-right corner.
65+
You can see that we do have results. The number of records that the query returns appears in the lower-right corner. The maximum number of results that you can retrieve in the Log Analytics portal experience is 30,000.
6166

6267
### Time range
6368

@@ -72,21 +77,30 @@ Let's change the time range of the query by selecting **Last 12 hours** from the
7277
7378
:::image type="content" source="media/log-analytics-tutorial/query-time-range.png" alt-text="Screenshot that shows the time range." lightbox="media/log-analytics-tutorial/query-time-range.png":::
7479

75-
### Multiple query conditions
80+
### Multiple filters
81+
82+
Let's reduce our results further by adding another filter condition. A query can include any number of filters to target exactly the set of records that you want. On the left side of the screen where the **Tables** tab is active, select the **Filter** tab instead. If you can't find it, click on the ellipsis to view more tabs.
83+
84+
On the **Filter** tab, select **Load old filters** to view the top 10 values for each filter.
7685

77-
Let's reduce our results further by adding another filter condition. A query can include any number of filters to target exactly the set of records that you want. Select **Get Home/Index** under **Name**, and then select **Apply & Run**.
86+
:::image type="content" source="media/log-analytics-tutorial/load-old-filters.png" alt-text="Screenshot that shows the query tab with the option to load old filters." lightbox="media/log-analytics-tutorial/load-old-filters.png":::
87+
88+
Select **Get Home/Index** under **Name**, then click on **Apply & Run**.
7889

7990
:::image type="content" source="media/log-analytics-tutorial/query-multiple-filters.png" alt-text="Screenshot that shows query results with multiple filters." lightbox="media/log-analytics-tutorial/query-multiple-filters.png":::
8091

8192
## Analyze results
8293

83-
In addition to helping you write and run queries, Log Analytics provides features for working with the results. Start by expanding a record to view the values for all of its columns.
94+
In addition to helping you write and run queries, Log Analytics provides features for working with the results. Start by expanding a record to view the values for all of its columns by clicking the chevron on the left side of the row.
8495

8596
:::image type="content" source="media/log-analytics-tutorial/expand-query-search-result.png" alt-text="Screenshot that shows a record expanded in the search results." lightbox="media/log-analytics-tutorial/expand-query-search-result.png":::
8697

8798
Select the name of any column to sort the results by that column. Select the filter icon next to it to provide a filter condition. This action is similar to adding a filter condition to the query itself, except that this filter is cleared if the query is run again. Use this method if you want to quickly analyze a set of records as part of interactive analysis.
8899

89-
For example, set a filter on the **DurationMs** column to limit the records to those that took more than **150** milliseconds.
100+
Set a filter on the **DurationMs** column to limit the records to those that took more than **150** milliseconds.
101+
102+
1. The results table allows you to filter just like in Excel. Select the ellipsis in the **Name** column header.
103+
1. Uncheck **Select All**, then search for **Get Home/Index** and check it. Filters are automatically applied to your results.
90104

91105
:::image type="content" source="media/log-analytics-tutorial/query-results-filter.png" alt-text="Screenshot that shows a query results filter." lightbox="media/log-analytics-tutorial/query-results-filter.png":::
92106

@@ -104,9 +118,9 @@ To better visualize your data, you can reorganize and summarize the data in the
104118

105119
Select **Columns** to the right of the results pane to open the **Columns** sidebar.
106120

107-
:::image type="content" source="media/log-analytics-tutorial/query-results-group-columns.png" alt-text="Screenshot that shows the Column link to the right of the results pane, which you select to open the Columns sidebar." lightbox="media/log-analytics-tutorial/query-results-group-columns.png":::
121+
:::image type="content" source="media/log-analytics-tutorial/query-results-columns.png" alt-text="Screenshot that shows the Column link to the right of the results pane, which you select to open the Columns sidebar." lightbox="media/log-analytics-tutorial/query-results-columns.png":::
108122

109-
In the sidebar, you'll see a list of all available columns. Drag the **Url** column into the **Row Groups** section. Results are now organized by that column, and you can collapse each group to help you with your analysis. This action is similar to adding a filter condition to the query, but instead of refetching data from the server, you're processing the data your original query returned. When you run the query again, Log Analytics retrieves data based on your original query. Use this method if you want to quickly analyze a set of records as part of interactive analysis.
123+
In the sidebar, you see a list of all available columns. Drag the **Url** column into the **Row Groups** section. Results are now organized by that column, and you can collapse each group to help you with your analysis. This action is similar to adding a filter condition to the query, but instead of refetching data from the server, you're processing the data your original query returned. When you run the query again, Log Analytics retrieves data based on your original query. Use this method if you want to quickly analyze a set of records as part of interactive analysis.
110124

111125
:::image type="content" source="media/log-analytics-tutorial/query-results-grouped.png" alt-text="Screenshot that shows query results grouped by URL." lightbox="media/log-analytics-tutorial/query-results-grouped.png":::
112126

@@ -128,15 +142,19 @@ Now let's sort the results by longest maximum call duration by selecting the **m
128142

129143
## Work with charts
130144

131-
Let's look at a query that uses numerical data that we can view in a chart. Instead of building a query, we'll select an example query.
145+
Let's look at a query that uses numerical data that we can view in a chart. Instead of building a query, we select an example query.
146+
147+
Select **Queries** on the left pane. This pane includes example queries that you can add to the query window. If you're using your own workspace, you should have various queries in multiple categories.<!-- If you're using the demo environment, you might see only a single **Log Analytics workspaces** category. Expand that to view the queries in the category. -->
148+
149+
Load the **Function Error rate** query in the **Applications** category to the editor. To do so, double-click the query or hover over the query name to show more information, then select **Load to editor**.
132150

133-
Select **Queries** on the left pane. This pane includes example queries that you can add to the query window. If you're using your own workspace, you should have various queries in multiple categories. If you're using the demo environment, you might see only a single **Log Analytics workspaces** category. Expand that to view the queries in the category.
151+
:::image type="content" source="media/log-analytics-tutorial/query-info.png" alt-text="Screenshot that shows info about the query." lightbox="media/log-analytics-tutorial/query-info.png":::
134152

135-
Select the query called **Function Error rate** in the **Applications** category. This step adds the query to the query window. Notice that the new query is separated from the other by a blank line. A query in KQL ends when it encounters a blank line, so these are considered separate queries.
153+
Notice that the new query is separated from the other by a blank line. A query in KQL ends when it encounters a blank line, making them separate queries.
136154

137155
:::image type="content" source="media/log-analytics-tutorial/example-query.png" alt-text="Screenshot that shows a new query." lightbox="media/log-analytics-tutorial/example-query.png":::
138156

139-
The current query is the one that the cursor is positioned on. You can see that the first query is highlighted, indicating that it's the current query. Click anywhere in the new query to select it, and then select the **Run** button to run it.
157+
Click anywhere in a query to select it, then click on the **Run** button to run it.
140158

141159
:::image type="content" source="media/log-analytics-tutorial/example-query-output-table.png" alt-text="Screenshot that shows the query results table." lightbox="media/log-analytics-tutorial/example-query-output-table.png":::
142160

-47.3 KB
Loading
-93 KB
Loading
-148 KB
Loading
-35.7 KB
Loading
59.8 KB
Loading
-54.7 KB
Loading
-13.2 KB
Loading
-60.4 KB
Loading
68.1 KB
Loading

0 commit comments

Comments
 (0)