Skip to content

Latest commit

 

History

History
74 lines (47 loc) · 3.86 KB

File metadata and controls

74 lines (47 loc) · 3.86 KB

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.

Screenshot of the standalone Aspire dashboard

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 10.0. It requires the .NET 10.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/aspire-dashboard:latest

The docker command:

  • Starts a container from the mcr.microsoft.com/dotnet/nightly/aspire-dashboard image.
  • The container has two ports:

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:

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.

Screenshot of the Aspire dashboard container logs

For more information about logging into the dashboard, see Dashboard authentication.

Running the sample

To download and run the sample, follow these steps:

  1. Clone the dotnet/aspire-samples repository.
  2. Navigate to the folder that holds the sample code.
  3. At the command line, type dotnet run ConsoleApp.cs.

Run the .NET app by executing the following at the command prompt (opened to the base directory of the sample):

dotnet run ConsoleApp.cs
  1. The console app launches, downloads information about the top NuGet packages and then exits.
  2. View the Aspire dashboard at http://localhost:18888 to see app telemetry.
    1. View structured logs to see the list of top NuGet packages.
    2. View traces to see HTTP requests made.
    3. 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 ConsoleApp.run.json file. Removing the OTEL_EXPORTER_OTLP_ENDPOINT value disables exporting telemetry.