Giter Site home page Giter Site logo

aspnetcore-grafana's Introduction

ASP.NET Core Grafana dashboards

.NET 8 adds new metrics throughout ASP.NET Core using System.Diagnostics.Metrics. Metrics is a modern API for reporting and collecting information about your apps.

If you're interested in trying out metrics, we've put together Grafana dashboards that report ASP.NET Core metrics collected by Prometheus. The dashboard JSON files are available in this repository, and you can import the Dashboards into Grafana.

Dashboards

Screenshot

ASP.NET Core Grafana dashboard

Export metrics from ASP.NET Core

ASP.NET Core metrics need to be exported to Prometheus. You can do this by configuring the OpenTelemetry .NET client.

Add OpenTelemetry packages to the project file:

<ItemGroup>
  <PackageReference Include="OpenTelemetry.Exporter.Prometheus.AspNetCore" Version="1.6.0-rc.1" />
  <PackageReference Include="OpenTelemetry.Extensions.Hosting" Version="1.6.0-rc.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");
        builder.AddView("http.server.request.duration",
            new ExplicitBucketHistogramConfiguration
            {
                Boundaries = new double[] { 0, 0.005, 0.01, 0.025, 0.05, 0.075, 0.1, 0.25, 0.5, 0.75, 1, 2.5, 5, 7.5, 10 }
            });
    });

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

app.Run();

Verify OpenTelemetry has been successfully configured by browsing to the /metrics endpoint on your app. 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.

aspnetcore-grafana's People

Contributors

eerhardt avatar jamesnk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.