Skip to content

Latest commit

 

History

History

Grafana

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

.NET Grafana dashboards

The .NET Grafana dashboards visualize metrics built into .NET. Use metrics to see the real-time status of your apps.

Get the dashboards

The best place to get the dashboards is from the Grafana dashboard store. The store has download links and instructions for importing dashboards into Grafana.

See Export metrics from .NET for information on configuring a .NET app to send data to the dashboards.

Screenshot

ASP.NET Core Grafana dashboard

Sample

.NET sample app that reports metrics to the dashboards is available at https://aka.ms/dotnet/grafana-sample.

Technology

The dashboards use built-in .NET APIs and OSS cloud-native tools:

  • System.Diagnostics.Metrics is the modern .NET metrics API. Libraries and apps use the API to create instruments and record values. ASP.NET Core and other .NET frameworks have built-in instruments for recording important information.
  • .NET OpenTelemetry SDK collects values from System.Diagnostics.Metrics instruments and exports values to Prometheus. OpenTelemetry needs to be configured in an application.
  • Prometheus is a metrics database. Prometheus scrapes metrics values from apps and then stores them in a database. Prometheus provides an API to query values.
  • Grafana is a visualization and report tool for building dashboards and sending alerts. Grafana uses Prometheus as its data source.

Source code

This repository is the home for the dashboard JSON files. We'd welcome issues and contributions to improve them.

Export metrics from .NET

.NET metrics must be exported to Prometheus. You can do this by configuring the .NET OpenTelemetry SDK.

Add OpenTelemetry packages to the project file:

<ItemGroup>
  <PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.7.0-alpha.1" />
  <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.7.0-alpha.1" />
</ItemGroup>

Configure OpenTelemetry at startup:

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenTelemetry()
    .WithMetrics(builder =>
    {
        builder.AddPrometheusExporter();
        builder.AddMeter("Microsoft.AspNetCore.Hosting", "Microsoft.AspNetCore.Server.Kestrel");
    });

var app = builder.Build();
app.MapPrometheusScrapingEndpoint();

app.Run();

Verify OpenTelemetry has been successfully configured by browsing your app's /metrics endpoint. It will return metrics data formatted to be scraped by Prometheus.

Configure Prometheus and Grafana

For information about setting up Prometheus and Grafana, see View metrics in Grafana with OpenTelemetry and Prometheus.