SOLVED
Home

Invoke-LogAnalyticsQuery only returns Tables JSON Array and not Results Array

Highlighted
Brady Evans
New Contributor

Invoke-LogAnalyticsQuery only returns Tables JSON Array and not Results Array

I'm trying to use the new PowerShell based API (Invoke-LogAnalyticsQuery - see below) and the return payload only includes the Tables array and not the Results array as documented..  

 

import-module .\LogAnalyticsQuery.psm1

$queryString = 'search * | where Type == "Heartbeat" | take 10'
$workspaceName = "xxxx"
$resourceGroupName = "xxxx"
$subscriptionID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

$response = invoke-loganalyticsquery -WorkspaceName $workspaceName -ResourceGroup $resourceGroupName -Query $queryString -SubscriptionId $subscriptionID -IncludeTabularView
2 Replies
Solution

Re: Invoke-LogAnalyticsQuery only returns Tables JSON Array and not Results Array

Hi Brady,

 

First, I must comment on your query. You should avoid queries that has 'search * | where Type =='. Instead the query below should just be: 'Heartbeat | take 10'. Search * is very inefficient way to use the system.

 

Regarding the results array. I ran the same code but didn't managed to reproduce. I got both tables and results.

 

Sorry

Meir

Re: Invoke-LogAnalyticsQuery only returns Tables JSON Array and not Results Array

Meir, thanks for the pointer on query optimization.  I did figure out that I am getting the results.  It seems the shape of the JSON result you get back from Invoke-LogAnalyticsQuery doesn't match what is documented at:

https://dev.loganalytics.io/documentation/Tools/PowerShell-Cmdlets.

 

Thanks again.

 

Related Conversations