Last active
March 12, 2021 13:24
-
-
Save gsscoder/3b1a5b39f528964b4cf9f03e6badced2 to your computer and use it in GitHub Desktop.
PowerShell code to query Azure App Insights using REST API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$aiAppId = '00000000-0000-0000-0000-000000000000' | |
$aiApiKey = 'ehzgdrES4kBJNCuRUzcBfkuka5CGWkAr4hyhJ6y3' | |
$result = Invoke-RestMethod -Uri "https://api.applicationinsights.io/v1/apps/$aiAppId/query" ` | |
-Method Post -UseBasicParsing ` | |
-Headers @{ | |
'x-api-key' = $aiApiKey | |
'content-type' = 'application/json' | |
} ` | |
-Body '{"query": "traces | where timestamp <= ago(1m) | limit 10"}' | |
$result.tables[0].rows.Length | Write-Host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment