Skip to content

Commit 285a32f

Browse files
authored
Merge pull request #256543 from guywi-ms/query-pack-updates
Query pack updates
2 parents 54b85ac + 1bdcd39 commit 285a32f

File tree

3 files changed

+27
-47
lines changed

3 files changed

+27
-47
lines changed
48.8 KB
Loading
190 KB
Loading

articles/azure-monitor/logs/query-packs.md

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,69 +13,39 @@ ms.date: 06/22/2022
1313
# Query packs in Azure Monitor Logs
1414
Query packs act as containers for log queries in Azure Monitor. They let you save log queries and share them across workspaces and other contexts in Log Analytics.
1515

16-
## View query packs
17-
You can view and manage query packs in the Azure portal from the **Log Analytics query packs** menu. Select a query pack to view and edit its permissions. This article describes how to create a query pack by using the API.
18-
19-
[![Screenshot that shows query packs.](media/query-packs/view-query-pack.png)](media/query-packs/view-query-pack.png#lightbox)
20-
2116
## Permissions
22-
You can set the permissions on a query pack when you view it in the Azure portal. Users require the following permissions to use query packs:
17+
You can set the permissions on a query pack when you view it in the Azure portal. You need the following permissions to use query packs:
2318

2419
- **Reader**: Users can see and run all queries in the query pack.
2520
- **Contributor**: Users can modify existing queries and add new queries to the query pack.
2621

2722
> [!IMPORTANT]
2823
> When a user needs to modify or add queries, always grant the user the Contributor permission on the `DefaultQueryPack`. Otherwise, the user won't be able to save any queries to the subscription, including in other query packs.
2924
25+
## View query packs
26+
You can view and manage query packs in the Azure portal from the **Log Analytics query packs** menu. Select a query pack to view and edit its permissions. This article describes how to create a query pack by using the API.
27+
28+
[![Screenshot that shows query packs.](media/query-packs/view-query-pack.png)](media/query-packs/view-query-pack.png#lightbox)
29+
3030
## Default query pack
31-
A query pack, called `DefaultQueryPack`, is automatically created in each subscription in a resource group called `LogAnalyticsDefaultResources` when the first query is saved. You can create queries in this query pack or create other query packs depending on your requirements.
31+
Azure Monitor automatically creates a query pack called `DefaultQueryPack` in each subscription in a resource group called `LogAnalyticsDefaultResources` when you save your first query. You can save queries to this query pack or create other query packs depending on your requirements.
3232

3333
## Use multiple query packs
34-
The single default query pack will be sufficient for most users to save and reuse queries. But there are reasons that you might want to create multiple query packs for users in your organization. For example, you might want to load different sets of queries in different Log Analytics sessions and provide different permissions for different collections of queries.
3534

36-
When you create a new query pack by using the API, you can add tags that classify queries according to your business requirements. For example, you could tag a query pack to relate it to a particular department in your organization or to severity of issues that the included queries are meant to address. By using tags, you can create different sets of queries intended for different sets of users and different situations.
35+
The default query pack is sufficient for most users to save and reuse queries. You might want to create multiple query packs for users in your organization if, for example, you want to load different sets of queries in different Log Analytics sessions and provide different permissions for different collections of queries.
3736

38-
## Query pack definition
39-
Each query pack is defined in a JSON file that includes the definition for one or more queries. Each query is represented by a block.
37+
When you [create a new query pack](#create-a-query-pack), you can add tags that classify queries based on your business needs. For example, you could tag a query pack to relate it to a particular department in your organization or to severity of issues that the included queries are meant to address. By using tags, you can create different sets of queries intended for different sets of users and different situations.
4038

41-
```json
42-
{
43-
"properties":
44-
{
45-
"displayName": "Query name that will be displayed in the UI",
46-
"description": "Query description that will be displayed in the UI",
47-
"body": "<<query text, standard KQL code>>",
48-
"related": {
49-
"categories": [
50-
"workloads"
51-
],
52-
"resourceTypes": [
53-
"microsoft.insights/components"
54-
],
55-
"solutions": [
56-
"logmanagement"
57-
]
58-
},
59-
"tags": {
60-
"Tag1": [
61-
"Value1",
62-
"Value2"
63-
]
64-
},
65-
}
66-
}
67-
```
39+
To add query packs to your Log Analytics workspace:
6840

69-
## Query properties
70-
Each query in the query pack has the following properties:
41+
1. Open Log Analytics and select **Queries** in the upper-right corner.
42+
1. In the upper-left corner on the **Queries** dialog, next to **Query packs**, click **0 selected**.
43+
1. Select the query packs that you want to add to the workspace.
7144

72-
| Property | Description |
73-
|:---|:---|
74-
| displayName | Display name listed in Log Analytics for each query. |
75-
| description | Description of the query displayed in Log Analytics for each query. |
76-
| body | Query written in Kusto Query Language. |
77-
| related | Related categories, resource types, and solutions for the query. Used for grouping and filtering in Log Analytics by the user to help locate their query. Each query can have up to 10 of each type. Retrieve allowed values from https://api.loganalytics.io/v1/metadata?select=resourceTypes, solutions, and categories. |
78-
| tags | Other tags used by the user for sorting and filtering in Log Analytics. Each tag will be added to Category, Resource Type, and Solution when you [group and filter queries](queries.md#find-and-filter-queries). |
45+
:::image type="content" source="media/query-packs/log-analytics-add-query-pack.png" alt-text="Screenshot that shows the Select query packs page in Log Analytics, where you can add query packs to a Log Analytics workspace." lightbox="media/query-packs/log-analytics-add-query-pack.png":::
46+
47+
> [!IMPORTANT]
48+
> You can add up to five query packs to a Log Analytics workspace.
7949
8050
## Create a query pack
8151
You can create a query pack by using the REST API or from the **Log Analytics query packs** pane in the Azure portal. To open the **Log Analytics query packs** pane in the portal, select **All services** > **Other**.
@@ -127,6 +97,16 @@ The payload of the request is the JSON that defines one or more queries and the
12797
}
12898
```
12999

100+
Each query in the query pack has the following properties:
101+
102+
| Property | Description |
103+
|:---|:---|
104+
| `displayName` | Display name listed in Log Analytics for each query. |
105+
| `description` | Description of the query displayed in Log Analytics for each query. |
106+
| `body` | Query written in Kusto Query Language. |
107+
| `related` | Related categories, resource types, and solutions for the query. Used for grouping and filtering in Log Analytics by the user to help locate their query. Each query can have up to 10 of each type. Retrieve allowed values from https://api.loganalytics.io/v1/metadata?select=resourceTypes, solutions, and categories. |
108+
| `tags` | Other tags used by the user for sorting and filtering in Log Analytics. Each tag will be added to Category, Resource Type, and Solution when you [group and filter queries](queries.md#find-and-filter-queries). |
109+
130110
### Create a request
131111
Use the following request to create a new query pack by using the REST API. The request should use bearer token authorization. The content type should be `application/json`.
132112

0 commit comments

Comments
 (0)