Skip to content

Commit 7982cbb

Browse files
committed
parameterized query
1 parent ddedafc commit 7982cbb

File tree

1 file changed

+83
-2
lines changed

1 file changed

+83
-2
lines changed

articles/azure-monitor/samples/arm-log-queries.md

Lines changed: 83 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ This article includes sample [Azure Resource Manager templates](../../azure-reso
1919

2020
- [Microsoft.OperationalInsights workspaces/savedSearches](/azure/templates/microsoft.operationalinsights/2020-03-01-preview/workspaces/savedsearches)
2121

22-
## Add a log query to a Log Analytics workspace
22+
## Simple log query
2323
The following sample adds a log query to a Log Analytics workspace.
2424

2525
### Template file
@@ -82,7 +82,7 @@ The following sample adds a log query to a Log Analytics workspace.
8282
}
8383
```
8484

85-
## Add a log query as a function to a Log Analytics workspace
85+
## Log query as a function
8686
The following sample adds a log query as a function to a Log Analytics workspace.
8787

8888
### Template file
@@ -151,6 +151,87 @@ The following sample adds a log query as a function to a Log Analytics workspace
151151
}
152152
```
153153

154+
## Parameterized function
155+
The following sample adds a log query as a function that uses a parameter to a Log Analytics workspace. A second log query is included that uses the parameterized function.
156+
157+
> [!NOTE]
158+
> Resource template is currently the only method that can be used to parameterized functions. Any log query can use the function once it's installed in the workspace.
159+
160+
### Template file
161+
162+
```json
163+
{
164+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
165+
"contentVersion": "1.0.0.0",
166+
"parameters": {
167+
"workspaceName": {
168+
"type": "string"
169+
},
170+
"location": {
171+
"type": "string"
172+
}
173+
},
174+
"resources": [
175+
{
176+
"type": "Microsoft.OperationalInsights/workspaces",
177+
"apiVersion": "2017-03-15-preview",
178+
"name": "[parameters('workspaceName')]",
179+
"location": "[parameters('location')]",
180+
"resources": [
181+
{
182+
"type": "savedSearches",
183+
"apiVersion": "2017-04-26-preview",
184+
"name": "Parameterized function",
185+
"dependsOn": [
186+
"[concat('Microsoft.OperationalInsights/workspaces/', parameters('workspaceName'))]"
187+
],
188+
"properties": {
189+
"etag": "*",
190+
"displayName": "Unavailable computers function",
191+
"category": "Samples",
192+
"FunctionAlias": "UnavailableComputers",
193+
"FunctionParameters": "argSpan: timespan",
194+
"query": " Heartbeat | summarize LastHeartbeat=max(TimeGenerated) by Computer| where LastHeartbeat < ago(argSpan)"
195+
}
196+
},
197+
{
198+
"type": "savedSearches",
199+
"apiVersion": "2017-04-26-preview",
200+
"name": "Query using function",
201+
"dependsOn": [
202+
"[concat('Microsoft.OperationalInsights/workspaces/', parameters('workspaceName'))]"
203+
],
204+
"properties": {
205+
"etag": "*",
206+
"displayName": "Unavailable computers",
207+
"category": "Samples",
208+
"query": "UnavailableComputers(7days)"
209+
}
210+
}
211+
]
212+
}
213+
]
214+
}
215+
216+
```
217+
218+
### Parameter file
219+
220+
```json
221+
{
222+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
223+
"contentVersion": "1.0.0.0",
224+
"parameters": {
225+
"workspaceName": {
226+
"value": "MyWorkspace"
227+
},
228+
"location": {
229+
"value": "eastus"
230+
}
231+
}
232+
}
233+
```
234+
154235

155236
## Next steps
156237

0 commit comments

Comments
 (0)