Nextended.Aspire.Hosting.Grafana 10.1.65

Prefix Reserved
dotnet add package Nextended.Aspire.Hosting.Grafana --version 10.1.65
                    
NuGet\Install-Package Nextended.Aspire.Hosting.Grafana -Version 10.1.65
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nextended.Aspire.Hosting.Grafana" Version="10.1.65" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nextended.Aspire.Hosting.Grafana" Version="10.1.65" />
                    
Directory.Packages.props
<PackageReference Include="Nextended.Aspire.Hosting.Grafana" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nextended.Aspire.Hosting.Grafana --version 10.1.65
                    
#r "nuget: Nextended.Aspire.Hosting.Grafana, 10.1.65"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nextended.Aspire.Hosting.Grafana@10.1.65
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nextended.Aspire.Hosting.Grafana&version=10.1.65
                    
Install as a Cake Addin
#tool nuget:?package=Nextended.Aspire.Hosting.Grafana&version=10.1.65
                    
Install as a Cake Tool

Nextended

Nextended.Aspire.Hosting.Grafana

NuGet Downloads License

Grafana, Prometheus, Loki, Tempo, Promtail, cAdvisor, postgres_exporter and the OpenTelemetry Collector as composable resources with auto-provisioned datasources.

Grafana

Runs Grafana as an Aspire resource.

๐Ÿ“– Documentation: English ยท Deutsch  |  ๐Ÿงช Runnable sample: Grafana.AppHost

Grafana observability stack for .NET Aspire โ€” Grafana, Prometheus, Loki, Tempo, Promtail, cAdvisor, postgres_exporter and OpenTelemetry Collector as composable container resources. Datasources are auto-provisioned, all YAML configs are generated at application start from the actual resource names โ€” no hardcoded config files, and the fluent calls work in any order.

Fluent API

var builder = DistributedApplication.CreateBuilder(args);

var pg = builder.AddPostgres("pg");

builder.AddGrafana("grafana")
    .WithAnonymousAdmin()                    // or .WithAdminUser("admin", password)
    .WithPrometheus(configure: p => p
        .WithRetention("30d")
        .WithScrapeTarget("api", "my-api:8080")
        .WithDataVolume())
    .WithLoki(configure: l => l.WithPromtail())  // Promtail ships all Docker container logs
    .WithTempo()
    .WithOtelCollector()                     // OTLP receiver, fans out to Tempo/Loki/Prometheus
    .WithCAdvisor()                          // per-container CPU/Memory/Network metrics
    .WithPostgresDatasource(pg)              // browse your DB from Grafana
    .WithPostgresExporter(pg)                // DB internals as Prometheus metrics
    .WithDashboards("./dashboards", "MyApp") // auto-loaded dashboard JSONs
    .WithDataVolume();                       // Grafana state survives container recreation

builder.Build().Run();

Every component call also provisions the matching Grafana datasource, wires start ordering (WaitFor) and nests the container under Grafana in the Aspire dashboard. Anything the typed methods don't cover goes through the escape hatch:

grafana.WithDatasource(new GrafanaDatasource
{
    Name = "MySQL",
    Type = "mysql",
    Url = "my-mysql:3306",
    User = "app",
});

One-call stack

using Nextended.Aspire.Hosting.Observability;

builder.AddObservabilityStack(new ObservabilityStackOptions
{
    ConfigRootPath = Path.Combine(builder.AppHostDirectory, "observability"),
    IncludeTempo = true,
    IncludeOtelCollector = true,
    GrafanaDashboardsFolder = "MyApp",
});

Nextended.Aspire.Hosting.Supabase builds on this package and adds an overload that derives the Postgres connection from a Supabase stack: builder.AddObservabilityStack(supabase, opts => โ€ฆ).

Deploying (Azure Container Apps)

In publish mode (aspire publish, azd up) the stack deploys without anything a container app cannot do:

  • No bind mounts. Generated configs, provisioning and dashboards are baked into small images under {configRoot}/.generated/publish/<resource>/ โ€” FROM the component's own image (WithImage/WithImageTag still apply), one COPY per file.
  • Internal components speak TCP on their own ports (Prometheus 9090, Loki 3100, Tempo 3200, collector 4318, postgres_exporter 9187), so every generated name:port address keeps working; Grafana stays HTTP. Deployed, the collector receives OTLP/HTTP only โ€” 4317 belongs to Tempo.
  • The collector drops the mirror to the local Aspire dashboard (unless you set your own endpoint) and logs one line per batch instead of every span.
  • Promtail and cAdvisor are left out (they need the host's Docker socket).

What a deployed stack should add โ€” all opt-in, credentials always as env vars (${VAR} in the files, no secret in an image):

builder.AddObservabilityStack(new ObservabilityStackOptions
{
    ConfigRootPath = Path.Combine(builder.AppHostDirectory, "observability"),
    LokiStorage = new S3StorageOptions
    {
        Endpoint = ReferenceExpression.Create($"{s3.Property(EndpointProperty.HostAndPort)}"), // host:port
        Bucket = "loki",                                                                      // must exist
        AccessKey = ReferenceExpression.Create($"{accessKey}"),
        SecretKey = ReferenceExpression.Create($"{secretKey}"),
    },
    TempoStorage = new S3StorageOptions { /* same, Bucket = "tempo" */ },
    GrafanaDatabase = new GrafanaDatabaseOptions
    {
        HostAndPort = ReferenceExpression.Create($"{db.Property(EndpointProperty.HostAndPort)}"),
        Password = ReferenceExpression.Create($"{grafanaDbPassword}"),
    },
    GrafanaEntraId = new GrafanaEntraIdOptions
    {
        TenantId = "<tenant id>",
        ClientId = "<app registration client id>",
        ClientSecret = ReferenceExpression.Create($"{builder.AddParameter("grafana-client-secret", secret: true)}"),
    },
});

Fluent equivalents: l.WithS3Storage(โ€ฆ) on Loki, t.WithS3Storage(โ€ฆ) on Tempo, grafana.WithDatabase(โ€ฆ), grafana.WithEntraIdLogin(โ€ฆ).

Entra ID sign-in turns off the login form, basic auth, anonymous access and Grafana's initial admin user โ€” the only way in is an account of the tenant holding one of the app roles Viewer, Editor, Admin or GrafanaAdmin (server admin); AllowedGroups narrows it further. The app registration needs the redirect URI {grafana-url}/login/azuread; GF_SERVER_ROOT_URL comes from Grafana's own endpoint.

Any other OpenID Connect provider โ€” Keycloak, Authentik, Auth0, Okta โ€ฆ โ€” goes through GrafanaOAuth (GrafanaOAuthOptions, fluent grafana.WithOAuthLogin(โ€ฆ)), locked down the same way; its redirect URI is {grafana-url}/login/generic_oauth. Grafana does no discovery there, so the auth, token and userinfo URLs are named. For Keycloak a realm is enough:

opts.GrafanaOAuth = GrafanaOAuthOptions.Keycloak(
    "https://sso.example.com/realms/company", "grafana",
    ReferenceExpression.Create($"{builder.AddParameter("grafana-client-secret", secret: true)}"));

Where the browser and Grafana reach Keycloak differently โ€” a Keycloak container next to Grafana is http://localhost:โ€ฆ for the browser and http://keycloak:8080 for Grafana โ€” pass the second as backchannelRealmUrl; Keycloak itself then needs KC_HOSTNAME (the browser's address) and KC_HOSTNAME_BACKCHANNEL_DYNAMIC=true, as in the runnable sample. Locally Grafana's root URL โ€” where the browser returns after signing in โ€” is the address the host sees, not the container-network name.

The preset reads the client roles grafana-admin, admin, editor and viewer from a roles claim โ€” in Keycloak a "User Client Role" mapper with token claim name roles, added to the ID token and userinfo. GrafanaOAuthOptions.Roles("groups", admins: ["ops"], viewers: ["staff"]) maps names in any claim array instead; someone matching none is turned away.

The accounts of a Supabase stack sign in with grafana.WithSupabaseLogin(supabase, roleAttributePath) from Nextended.Aspire.Hosting.Supabase โ€” Supabase Auth as provider, a public client with PKCE, the role from a claim of the access token (e.g. GrafanaOAuthOptions.Roles("permissions", grafanaAdmins: ["grafana.manage"])). In AddObservabilityStack it goes into ConfigureGrafana, which runs on the Grafana resource after all other options.

With Nextended.Aspire.Hosting.Supabase, AddObservabilityStack(supabase, โ€ฆ) sets storage and database up from the Supabase stack itself.

Notes

  • Promtail and cAdvisor need the host's Docker socket โ€” they are automatically skipped in publish mode (azd up).
  • Generated configs land under {configRoot}/.generated/ so you can inspect what the containers actually loaded.
  • Secrets (datasource passwords) flow through container env vars; the generated YAML only contains ${VAR} references.

Supported frameworks

  • net8.0
  • net9.0
  • net10.0

Dependencies

  • Aspire.Hosting.AppHost
  • Aspire.Hosting.PostgreSQL

The Nextended family

The other 18 packages in the suite:

Core libraries

  • Nextended.Core โ€” Foundation library โ€” extension methods, custom types (Money, Date, BaseId, SuperType), class mapping, deep clone, encryption, hashing and the code-generation attributes.
  • Nextended.Cache โ€” Expression-based caching โ€” automatic cache keys from method expressions, CacheProvider with condition-based invalidation, thread-safe AddOrGetExisting.

Data access

  • Nextended.EF โ€” Entity Framework Core extensions โ€” graph loading (LoadGraphAsync, IncludeAll, MultiInclude), declarative include definitions, paging, dynamic sorting and bulk operations.

ASP.NET Core & web

  • Nextended.Web โ€” ASP.NET Core utilities โ€” zero-config OData (AddODataAuto), composable IQueryable OData appliers, strongly typed controller URLs, streaming download helpers and a background executor that can replay a captured request.
  • Nextended.ResponseFilters โ€” Fluent, provider-agnostic pipeline that redacts, masks, rounds, truncates, hashes, prunes and restructures response DTOs before serialization โ€” per request, per user, per permission.
  • Nextended.ResponseFilters.AspNetCore โ€” ASP.NET Core adapter for Nextended.ResponseFilters โ€” registers the pipeline as a global IAsyncResultFilter and replays structural edits against the serialized JSON tree.

UI libraries

  • Nextended.Blazor โ€” Blazor helpers โ€” IBrowserFile extensions (bytes, data URLs, downloads), a hierarchical model for browsing inside uploaded zip/tar/rar archives, MIME-type detection and component-parameter reflection.
  • Nextended.UI โ€” WPF and Windows desktop helpers โ€” a global input-binding manager with hold/sequence matching, DirectInput and XInput gamepad readers, key-bind capture controls, converters, behaviours, markup extensions and runtime-defined PropertyGrid types.

Code generation & tooling

  • Nextended.Imaging โ€” Image processing โ€” aspect-preserving resize, crop, colour replacement, brightness-based foreground picking, thumbnail generation, byte/data-URL conversion and MIME detection from magic bytes.
  • Nextended.CodeGen โ€” Roslyn source generator โ€” DTOs and interfaces from your entities, strongly typed classes from JSON/XML, lookup tables from Excel, documentation from source files, and TypeScript declarations of your contracts.

.NET Aspire hosting

  • Nextended.Aspire โ€” Conditional AppHost builder extensions โ€” WithReferenceIf / WaitForIf / WithExplicitStartIf, strongly typed environment variables from config objects, HTTPS dev-cert wiring, Docker guards, GitHub-source resources and npm app discovery.
  • Nextended.Aspire.Hosting.Supabase โ€” The complete Supabase stack โ€” Postgres, Auth (GoTrue), REST, Realtime, Storage, Studio, Kong and Edge Functions โ€” as one composable Aspire resource.
  • Nextended.Aspire.Hosting.N8n โ€” The n8n workflow-automation platform as an Aspire resource, with Postgres persistence, workflow import and a typed client for triggering workflows from .NET.
  • Nextended.Aspire.Hosting.Grafana โ€” Grafana, Prometheus, Loki, Tempo, Promtail, cAdvisor, postgres_exporter and the OpenTelemetry Collector as composable resources with auto-provisioned datasources. (this package)
  • Nextended.Aspire.Hosting.WebDataStudio โ€” WebDataStudio โ€” a browser database studio for PostgreSQL, MySQL, SQL Server, SQLite, Oracle, DuckDB, ClickHouse, MongoDB and Redis โ€” wired to the databases of your stack, with accounts and roles, an optional SQL assistant, and an MCP endpoint for AI agents.
  • Nextended.Aspire.Hosting.AspireUI โ€” AspireUI โ€” the visual AppHost builder โ€” as a resource inside your own Aspire stack, with an optional pre-seeded admin user and a starter stack built from your project paths.
  • Nextended.Aspire.Hosting.LocalAI โ€” Self-hosted, OpenAI-compatible multimodal AI โ€” image generation, text-to-speech, speech-to-text and video โ€” with gallery model management, GPU support and Open WebUI.
  • Nextended.Aspire.Hosting.Php โ€” Run PHP endpoints inside your Aspire stack โ€” a docroot folder or a single router script served by PHP's built-in web server, with php.ini settings as fluent options.
  • Nextended.Aspire.Hosting.DbTools โ€” Database tools for an Aspire app host. The first: fill a database resource from a database that already exists โ€” schema and data โ€” from another resource in the stack or from a server it does not model. PostgreSQL, SQL Server, MySQL/MariaDB, MongoDB and Redis, each through its own engine's dump and restore tools.

License

MIT โ€” see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Nextended.Aspire.Hosting.Grafana:

Package Downloads
Nextended.Aspire.Hosting.Supabase

This Library provides an Aspire Supabase solution

Coworkee.Aspire

AddCoworkeeApp() for the Aspire app host: migrations, auth server, APIs, workers and web wired with Postgres (or SQL Server, SQLite), Redis, Mailpit, Elasticsearch and Keycloak.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.1.65 110 11/14/2026
10.1.64 91 11/13/2026
10.1.63 89 11/12/2026
10.1.62 74 11/12/2026
10.1.61 108 11/12/2026
10.1.60 73 11/12/2026
10.1.59 97 11/12/2026
10.1.58 77 11/11/2026
10.1.57 78 11/11/2026
10.1.56 85 11/11/2026
10.1.55 110 11/11/2026
10.1.54 87 11/11/2026
10.1.53 114 11/8/2026
10.1.52 116 11/6/2026
10.1.51 371 11/5/2026
10.1.50 132 10/30/2026
10.1.49 125 10/29/2026
10.1.48 507 10/27/2026
10.1.47 195 10/25/2026
10.1.46 179 10/16/2026
Loading failed