Query exceptions, requests, structured logs, and dependency spans from Azure Application Insights in your terminal, without opening the Azure Portal.
pks otel <command> [options]$ pks otel errors --since 6hRecent exceptions across every instrumented app
$ pks otel traces --has-error --since 24hFailed requests over the last day
$ pks otel logs --severity Error --since 7dErrors and above from application logs
$ pks otel spans --operation-id abc123Dependency-call waterfall for one trace
pks otel is the read-only telemetry query group in the pks CLI. It runs canned KQL (Kusto Query Language) against an Azure Application Insights resource and prints the result as a table or as JSON.
pks otel wraps the Application Insights REST Query API (https://api.applicationinsights.io/v1/apps/{appId}/query) behind four commands. Instead of opening the Azure Portal and writing a query by hand, you ask for the four things you actually want during an incident.
pks otel errors reads the exceptions table, newest first, so you see what broke.pks otel traces reads the requests table — duration, success flag, result code — so you see which endpoints are slow or failing.pks otel logs reads the traces table, filtered by minimum severity or by a single trace ID.pks otel spans reads the dependencies table for one operation ID, oldest first — the waterfall of what that request called.--format Json writes compact JSON through plain standard output, bypassing the Spectre.Console renderer, so | jq sees no ANSI escapes or markup.pks appinsights init and the Azure AD identity established by pks foundry init.Each command builds a KQL string, asks IAzureFoundryAuthService for an access token scoped to https://api.applicationinsights.io/.default, and POSTs the query to the App Insights query endpoint for the configured App ID. Nothing is cached, nothing is streamed, and nothing is written back — every invocation is a single point-in-time query over a bounded time window.
That means two prerequisites, both owned by other command groups. pks appinsights init stores the App ID (plus resource name and subscription ID) in the global pks config. pks foundry init signs you in to Azure AD. pks otel itself has no init and no login subcommand.
otel errors / otel traces / otel logs are app-wide scans over a window you choose.otel spans is a single-trace drill-down with a fixed 24-hour window.errors · traces · logs · spans
Four commands, no aliases and no hidden subcommands. Full flag detail lives on the pks otel command reference.
| Command | Application Insights table | Scope |
|---|---|---|
pks otel errors | exceptions | App-wide or one operation ID, newest first. |
pks otel traces | requests | App-wide, optionally errors only. |
pks otel logs | traces | App-wide, filtered by minimum severity or trace ID. |
pks otel spans | dependencies | One operation ID, fixed 24-hour window. |
| Setting | Value |
|---|---|
Time window (errors, traces, logs) | 1h |
Time window (spans) | 24h, not configurable |
| Result cap | 20 rows |
| Output format | Table |
Nothing in this group reads an environment variable. The App ID and the Azure AD sign-in come from pks appinsights init and pks foundry init.
Find the exception behind a production failure: scan recent errors from Application Insights, narrow by app and time window, then pivot on an operation ID.
pks otel errors [APP] [options]
Complete command, argument, and flag reference for the pks otel telemetry query group — errors, traces, logs, spans, prerequisites, and behavioral gaps.
pks otel <command> [options]
Show the outbound dependency calls a single request made — HTTP, database, and more — ordered oldest first, for one Application Insights operation ID.
pks otel spans --operation-id <ID> [options]
List recent requests from Application Insights with duration, result code, and success flag, then take an operation ID into the exception and span views.
pks otel traces [APP] [options]