コンテンツにスキップ
Docs Try Aspire
Docs Try

APIs and data access

このコンテンツはまだ日本語訳がありません。

The Aspire dashboard exposes APIs for both receiving and querying telemetry data. Applications write data to the dashboard using OpenTelemetry Protocol (OTLP) endpoints, and developers and tools read data back through the Aspire CLI, the Aspire MCP server, or the HTTP telemetry API.

The dashboard receives telemetry from applications using OpenTelemetry Protocol (OTLP) endpoints. Any application instrumented with an OpenTelemetry SDK can send traces, logs, and metrics to the dashboard.

The dashboard supports all OTLP transports:

TransportProtocol
gRPCOTLP/gRPC — Protobuf over gRPC
HTTPOTLP/HTTP — Protobuf or JSON over HTTP

When the dashboard is started by an Aspire AppHost, ports are automatically configured and mapped to standard OTLP ports (4317 for gRPC, 4318 for HTTP) on resource containers. In standalone mode, you configure the port mappings yourself — see Standalone Aspire dashboard for examples.

To configure applications to send telemetry, set the standard OpenTelemetry environment variables:

  • OTEL_EXPORTER_OTLP_ENDPOINT — the dashboard’s OTLP endpoint (e.g. http://localhost:4317 for gRPC or http://localhost:4318 for HTTP)
  • OTEL_EXPORTER_OTLP_PROTOCOLgrpc, http/protobuf, or http/json

The OTLP endpoints can be secured with API key or client certificate authentication. For configuration details, see OTLP authentication.

There are several ways to read telemetry and resource data from the dashboard.

The Aspire CLI provides commands for reading telemetry from the dashboard directly in the terminal:

CommandDescription
aspire otel logsQuery structured logs collected by the dashboard.
aspire otel tracesList distributed traces collected by the dashboard.
aspire otel spansQuery trace spans collected by the dashboard.

All commands support --format Json for structured output suitable for scripting and automation. To use these commands with a standalone dashboard, specify --dashboard-url to point at the dashboard instance.

The aspire export command packages telemetry and resource data from a running AppHost into a zip file. Use it to collect diagnostics for troubleshooting, share runtime state with a teammate, or preserve data for later analysis:

Aspire CLI
aspire export --output ./diagnostics.zip

You can also scope the export to a single resource:

Aspire CLI
aspire export webfrontend

The exported zip file can be imported back into the dashboard using the import feature UI.

To export with a standalone dashboard, specify --dashboard-url to point at the dashboard instance.

The Aspire MCP server exposes dashboard data to AI coding agents through the Model Context Protocol. MCP tools like list_structured_logs, list_traces, and list_console_logs provide the same data available through the HTTP API and CLI commands, allowing agents to query telemetry programmatically.

For more information on using AI coding agents with the dashboard, see Dashboard and AI coding agents.

The dashboard exposes HTTP endpoints under /api/telemetry/ that return data in OTLP JSON format. Available endpoints:

  • GET /api/telemetry/resources — List resources that have telemetry data
  • GET /api/telemetry/logs — Query logs with optional filters. Returns OTLP ResourceLogs JSON.
  • GET /api/telemetry/spans — Query spans with optional filters. Returns OTLP ResourceSpans JSON.
  • GET /api/telemetry/traces — Get all spans for traces that match optional filters. Returns OTLP ResourceSpans JSON.
  • GET /api/telemetry/traces/{traceId} — Get all spans for a specific trace. Returns OTLP ResourceSpans JSON.

The spans and logs endpoints support real-time streaming via ?follow=true, which returns NDJSON (newline-delimited JSON) as new telemetry arrives. Multiple resource names can be specified by repeating the resource query parameter (e.g. ?resource=api&resource=worker).

The API is protected by configurable authentication. See API configuration for authentication options and settings.