You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-monitor/logs/query-packs.md
+27-47Lines changed: 27 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,69 +13,39 @@ ms.date: 06/22/2022
13
13
# Query packs in Azure Monitor Logs
14
14
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.
15
15
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
-
[](media/query-packs/view-query-pack.png#lightbox)
20
-
21
16
## 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:
23
18
24
19
-**Reader**: Users can see and run all queries in the query pack.
25
20
-**Contributor**: Users can modify existing queries and add new queries to the query pack.
26
21
27
22
> [!IMPORTANT]
28
23
> 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.
29
24
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
+
[](media/query-packs/view-query-pack.png#lightbox)
29
+
30
30
## 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.
32
32
33
33
## 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.
35
34
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.
37
36
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.
40
38
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:
68
40
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.
71
44
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.
79
49
80
50
## Create a query pack
81
51
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
127
97
}
128
98
```
129
99
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
+
130
110
### Create a request
131
111
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`.
0 commit comments