Skip to content

Latest commit

 

History

History

README.md

Aspire metrics sample app

This is a simple .NET app that shows off collecting metrics with OpenTelemetry and exporting them to Prometheus and Grafana for reporting.

Screenshot of the ASP.NET Core Grafana dashboard

The instrumented app is a small web UI that emits OpenTelemetry metrics. Click around it — the Weather feed and the Auth Required flow — to generate the request traffic that shows up on the Grafana dashboard above. It supports both light and dark themes:

The metrics app home page in light mode The metrics app home page in dark mode

The metrics app weather feed in light mode The metrics app weather feed in dark mode

Demonstrates

  • How to configure an Aspire app to export metrics to Prometheus
  • How to add Prometheus and Grafana containers to an Aspire app
  • How to configure Prometheus and Grafana to collect and display metrics in the .NET Grafana dashboard

Sample prerequisites

Running the sample

If using the Aspire CLI, run aspire run from this directory.

If using VS Code, open this directory as a workspace and launch the MetricsApp.AppHost project using either the Aspire or C# debuggers.

If using Visual Studio, open the solution file Metrics.slnx and launch/debug the MetricsApp.AppHost project.

If using the .NET CLI, run dotnet run from the MetricsApp.AppHost directory.

  1. On the Resources page, click the URLsfor the instrumented app. This launches the simple .NET app.
  2. In the instrumented app:
    1. Visit the Weather and Auth Required pages to generate metrics. Values will be captured for http.server.request.duration and other instruments.
    2. On the Home page, click the Grafana dashboard link. This launches the ASP.NET Core dashboard in Grafana.
  3. Play around inside the Grafana dashboard:
    1. Change the time range.
    2. Enable auto-refresh.
    3. Click route links to view detailed information about specific areas in the ASP.NET Core app.

For more information about using Grafana dashboards, see the Grafana documentation.