Standalone Aspire dashboard sample app
View telemetry from any app in the Aspire dashboard. The dashboard supports running standalone, and apps configured with an OpenTelemetry SDK can send it data.
This sample is a .NET console app that downloads data from NuGet. The app sends telemetry to the Aspire dashboard which is viewed in the dashboard telemetry UI.
Demonstrates
- How to run the Aspire dashboard from a Docker container
- How to configure a .NET app to export telemetry to the dashboard
- How to view telemetry in the Aspire dashboard
Sample prerequisites
This sample is written in C# and targets .NET 8.0. It requires the .NET 8.0 SDK or later.
This sample runs the Aspire dashboard from a Docker container. It requires Docker to be installed.
Start Aspire dashboard
The following command starts the Aspire dashboard in a Docker container:
docker run --rm -it -p 18888:18888 -p 4317:18889 -d --name aspire-dashboard mcr.microsoft.com/dotnet/nightly/aspire-dashboard:8.0.0-preview.6
The docker command:
- Starts a container from the
mcr.microsoft.com/dotnet/nightly/aspire-dashboard
image. - The container has two ports:
- Port
4317
receives OpenTelemetry data from apps. Apps send data using OpenTelemetry Protocol (OTLP). - Port
18888
has the dashboard UI. Navigate to http://localhost:18888 in the browser to view the dashboard.
- Port
Note
The dashboard currently only supports the OTLP/gRPC protocol. Apps sending telemetry to the dashboard must be configured to use the grpc
protocol. There are a couple of options for configuring apps:
- Configure the OpenTelemetry SDK inside the app to use the gRPC OTLP protocol, or
- Start the app with the
OTEL_EXPORTER_OTLP_PROTOCOL
environment variable with a value ofgrpc
.
Login to the Aspire dashboard
Data displayed in the dashboard can be sensitive. By default, the dashboard is secured with authentication that requires a token to login.
When the dashboard is run from a standalone container the login token is printed to the container logs. After copying the highlighted token into the login page, select the Login button.
For more information about logging into the dashboard, see Dashboard authentication.
Building the sample
To download and run the sample, follow these steps:
- Clone the
dotnet/aspire-samples
repository. - In Visual Studio (2022 or later):
- On the menu bar, choose File > Open > Project/Solution.
- Navigate to the folder that holds the sample code, and open the solution (.sln) file.
- Choose the F5 key to run with debugging, or Ctrl+F5 keys to run the project without debugging.
- From the command line:
- Navigate to the folder that holds the sample code.
- At the command line, type
dotnet run
.
Run the .NET app by executing the following at the command prompt (opened to the base directory of the sample):
dotnet run --project ConsoleApp
- The console app launches, downloads information about the top NuGet packages and then exits.
- View the Aspire dashboard at http://localhost:18888 to see app telemetry.
- View structured logs to see the list of top NuGet packages.
- View traces to see HTTP requests made.
- View metrics to see numeric data about the app such as average HTTP request duration.
Configure OpenTelemetry
The telemetry export endpoint is configured with the OTEL_EXPORTER_OTLP_ENDPOINT
setting. This value is set to http://localhost:4317
in the sample's Properties/launchSettings.json
file. Removing the OTEL_EXPORTER_OTLP_ENDPOINT
value disables exporting telemetry.