0

I would like to execute my application insights traces from my vscode's azure cli command.
I could get all details with the below command.
az monitor app-insights query --app myappinsight1 --analytics-query traces --resource-group myRG
But I need more granular filters like dump only logs of last 10 minutes.
Using traces | where timestamp > ago(10min) in Azure portal appinsights query editor works fine, but gives error with azure cli command.
Here is my query az monitor app-insights query --app myappinsight1 --analytics-query traces | where timestamp > ago(10min) --resource-group myRG
I tried making quotes or escaping around symbols but didn't work.
Can anybody please help what wrong I am doing in the query?

Ecstasy
  • 1,866
  • 1
  • 9
  • 17
shivappa
  • 153
  • 1
  • 11

1 Answers1

0

Looks in case of make granular filters on the query, we need to quote with " for the query.
In my case quote for traces command is "traces | where timestamp > ago(10min)".
Complete CLI command with which I can get the logs:
az monitor app-insights query --app myappinsight1 --analytics-query "traces | where timestamp > ago(10min)" --resource-group myRG

shivappa
  • 153
  • 1
  • 11