Rob Bos
Rob Bos

Reputation: 1471

Run Azure Log Analytics query against Application Insights instances

I'm using the Azure Log Analytics .NET SDK to execute queries. The NuGet package I'm using for this SDK is Microsoft.Azure.OperationalInsights.

Querying against a normal Workspace is fine.

Now I want to query against an Application Insights resource, like you can do in the portal via the 'Analytics' button on an Application Insights blade. For this I need a WorkspaceId, that I cannot find on the resource.

Is there a way to run these queries via the OperationalInsights SDK or do I need to create my own wrapper around the Application Insights API? That seems to add extra authentication via the token, which I'd rather not need (I already have access to Log Analytics).

Upvotes: 0

Views: 378

Answers (1)

Rob Bos
Rob Bos

Reputation: 1471

Found out that you can query across workspaces and even across apps.

For apps, use app(appName) like so:

app('AppInsightsName').requests

For a different workspace, use this:

workspace("workspaceId").request

Upvotes: 1

Related Questions