app() expression in Azure Monitor query
app expression is used in an Azure Monitor query to retrieve data from a specific Application Insights app in the same resource group, another resource group, or another subscription. This is useful to include application data in an Azure Monitor log query and to query data across multiple applications in an Application Insights query.
The app() expression is not used if you're using a workspace-based Application Insights resource since log data is stored in a Log Analytics workspace. Use the log() expression to write a query that includes application in multiple workspaces. For multiple applications in the same workspace, you don't need a cross workspace query.
- Identifier: Identifies the app using one of the formats in the table below.
|Resource Name||Human readable name of the app (Also known as "component name")||app("fabrikamapp")|
|Qualified Name||Full name of the app in the form: "subscriptionName/resourceGroup/componentName"||app('AI-Prototype/Fabrikam/fabrikamapp')|
|ID||GUID of the app||app("988ba129-363e-4415-8fe7-8cbab5447518")|
|Azure Resource ID||Identifier for the Azure resource||app("/subscriptions/7293b69-db12-44fc-9a66-9c2005c3051d/resourcegroups/Fabrikam/providers/microsoft.insights/components/fabrikamapp")|
- You must have read access to the application.
- Identifying an application by its name assumes that it is unique across all accessible subscriptions. If you have multiple applications with the specified name, the query will fail because of the ambiguity. In this case you must use one of the other identifiers.
- Use the related expression workspace to query across Log Analytics workspaces.
- The app() expression is currently not supported in the search query when using the Azure portal to create a custom log search alert rule, unless an Application Insights application is used as the resource for the alert rule.
app("fabrikamapp").requests | count
app("AI-Prototype/Fabrikam/fabrikamapp").requests | count
app("b438b4f6-912a-46d5-9cb1-b44069212ab4").requests | count
app("/subscriptions/7293b69-db12-44fc-9a66-9c2005c3051d/resourcegroups/Fabrikam/providers/microsoft.insights/components/fabrikamapp").requests | count
union (workspace("myworkspace").Heartbeat | where Computer contains "Con"), (app("myapplication").requests | where cloud_RoleInstance contains "Con") | count
union (workspace("myworkspace").Heartbeat), (app("myapplication").requests) | where TimeGenerated between(todatetime("2018-02-08 15:00:00") .. todatetime("2018-12-08 15:05:00"))