Skip to content

feat: add Loki hosting integration - #2247

Open
meysamhadeli wants to merge 10 commits into
CommunityToolkit:mainfrom
meysamhadeli:feat/add-aspire-hosting-loki
Open

meysamhadeli wants to merge 10 commits into
CommunityToolkit:mainfrom
meysamhadeli:feat/add-aspire-hosting-loki

Conversation

@meysamhadeli

Copy link
Copy Markdown

Overview

Adds a preview CommunityToolkit.Aspire.Hosting.Loki hosting integration for running Grafana Loki in Aspire.

Includes:

  • Loki container resource with HTTP and gRPC endpoints
  • Configurable image, registry, tag, ports, health checks, and gRPC support
  • Connection string and connection properties
  • Persistent volume and bind-mount helpers
  • Custom Loki configuration bind mounts
  • C# and TypeScript AppHost examples
  • API and ServiceDefaults example projects
  • Resource, publishing, persistence, and TypeScript tests
  • Package README and root integration catalog entry

Outstanding validation differences:

  • Full AppHost validation requires Aspire CLI bundle setup.
  • TypeScript validation requires PowerShell.
  • Docker runtime tests require a working Linux container runtime.

PR Checklist

  • Created a feature/dev branch in your fork
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits
  • New integration
    • Docs are written
    • Added package description and tags
  • Tests for the changes have been added
  • Contains NO breaking changes
  • Every new public API has full XML docs
  • Code follows repository style conventions

Other information

This is a new preview hosting integration. CI test discovery includes Hosting.Loki.Tests.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 13:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The gRPC endpoint advertises an unusable TCP URI, and persistence cleanup plus polyglot validation and documentation need correction.

5 open findings
What changed in this PR

Adds a preview Loki hosting integration as a standalone container-backed Aspire service with C#, TypeScript, publishing, persistence, and functional coverage.

Changes:

  • Adds Loki resource APIs, endpoints, health checks, connection properties, and mount helpers.
  • Adds C# and TypeScript examples plus package documentation.
  • Adds app-model, manifest, runtime, persistence, and TypeScript tests.
File Description
README.md Adds Loki to the integration catalog.
CommunityToolkit.Aspire.slnx Registers source, test, and example projects.
src/​CommunityToolkit.Aspire.Hosting.Loki/​CommunityToolkit.Aspire.Hosting.Loki.csproj Defines the preview package.
src/​CommunityToolkit.Aspire.Hosting.Loki/​LokiBuilderExtensions.cs Implements Loki registration and mount helpers.
src/​CommunityToolkit.Aspire.Hosting.Loki/​LokiResource.cs Defines endpoints and connection properties.
src/​CommunityToolkit.Aspire.Hosting.Loki/​LokiSettings.cs Defines configurable container settings.
src/​CommunityToolkit.Aspire.Hosting.Loki/​README.md Documents basic C# usage.
tests/​CommunityToolkit.Aspire.Hosting.Loki.Tests/​CommunityToolkit.Aspire.Hosting.Loki.Tests.csproj Defines the test project.
tests/​CommunityToolkit.Aspire.Hosting.Loki.Tests/​ResourceCreationTests.cs Tests app-model and manifest behavior.
tests/​CommunityToolkit.Aspire.Hosting.Loki.Tests/​LokiFunctionalTests.cs Tests storage persistence.
tests/​CommunityToolkit.Aspire.Hosting.Loki.Tests/​TypeScriptAppHostTests.cs Validates TypeScript startup.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost/​AppHost.cs Demonstrates C# orchestration.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost/​CommunityToolkit.Aspire.Hosting.Loki.AppHost.csproj Configures the C# AppHost.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost/​appsettings.json Configures AppHost logging.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost/​Properties/​launchSettings.json Adds AppHost launch profiles.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost.TypeScript/​apphost.mts Demonstrates TypeScript orchestration.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost.TypeScript/​aspire.config.json Maps the local integration package.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost.TypeScript/​package.json Defines TypeScript tooling.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost.TypeScript/​package-lock.json Locks TypeScript dependencies.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost.TypeScript/​tsconfig.json Configures TypeScript compilation.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.AppHost.TypeScript/​eslint.config.mjs Configures TypeScript linting.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.Api/​Program.cs Adds the example API.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.Api/​CommunityToolkit.Aspire.Hosting.Loki.Api.csproj Configures the API project.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.Api/​CommunityToolkit.Aspire.Hosting.Loki.Api.http Adds a sample API request.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.Api/​appsettings.json Configures API logging.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.Api/​Properties/​launchSettings.json Adds the API launch profile.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.ServiceDefaults/​Extensions.cs Adds shared telemetry and health defaults.
examples/​loki/​CommunityToolkit.Aspire.Hosting.Loki.ServiceDefaults/​CommunityToolkit.Aspire.Hosting.Loki.ServiceDefaults.csproj Defines ServiceDefaults dependencies.
Files not reviewed (1)
  • examples/loki/CommunityToolkit.Aspire.Hosting.Loki.AppHost.TypeScript/package-lock.json: Generated file

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@meysamhadeli

Copy link
Copy Markdown
Author

@meysamhadeli please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@dotnet-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@dotnet-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@dotnet-policy-service agree company="Microsoft"

Contributor License Agreement

@dotnet-policy-service agree

@aaronpowell aaronpowell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple questions on the csproj

@meysamhadeli

Copy link
Copy Markdown
Author

Couple questions on the csproj

Hi @aaronpowell,

Thanks for checking my PR.
I've resloved the issues.

@aaronpowell aaronpowell added this to the 17.0 milestone Nov 3, 2026
@aaronpowell

Copy link
Copy Markdown
Member

All good from me.

@afscrome - anything from a rereview?

@Laurianti Laurianti self-assigned this Nov 3, 2026

@Laurianti Laurianti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked these on main (c2b3edb) with this PR (8afbc5f) merged. With all the changes suggested below, the example AppHost builds, a gRPC call to loki.Resource.GrpcEndpoint returns grpc-status: 0, and the 25 Loki tests other than the TypeScript one pass with 3.6.19. I didn't run the TypeScript test.

Comment thread README.md Resolved
"language": "typescript/nodejs"
},
"sdk": {
"version": "13.6.1"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#2338 moved all 57 TypeScript examples to 17.0.0-preview.1.26552.6. This one still has 13.6.1.

Suggested change
"version": "13.6.1"
"version": "17.0.0-preview.1.26552.6"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for flagging this. I’ll check whether the example works with the updated dependencies on main and align the SDK version if needed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On main with this PR, the Loki TypeScript test fails with 13.6.1: aspire restore stops with NU1103, because it can't find Aspire.Hosting and Aspire.Hosting.CodeGeneration.TypeScript 13.6.1. With 17.0.0-preview.1.26552.6, the version the other 56 TypeScript examples use, the test passes. I used Aspire CLI 17.0.0-preview.1.26552.6, the version CI installs, on Windows.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it will need to be bumped to the 17.0.0 preview because it won't compile the dependencies for the TypeScript tests.

Just double-check the version before committing, as we're doing nightly updates of the packages to ensure we don't have any gaps on the 17 release.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aaronpowell
Thanks for catching that! I’ve bumped the Loki TypeScript AppHost to 17.0.0-preview.1.26552.6 to match the repo’s current dependencies. I’ll push the change to trigger CI again and check whether it fixes the failing test.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main has moved to 17.0.0-preview.1.26553.5, which the other 56 TypeScript examples now use. With 26552.6, on main with this PR, the Loki TypeScript test still fails, now with NU1605: CommunityToolkit.Aspire.Hosting.Loki brings Aspire.Hosting 26553.5 and the example asks for 26552.6. With 26553.5 the test passes. I used Aspire CLI 17.0.0-preview.1.26553.5, the version CI installs now, on Windows.

@meysamhadeli meysamhadeli Nov 5, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Laurianti @aaronpowell
Thanks for catching this and testing it on Windows! I’ve updated Loki to 17.0.0-preview.1.26553.5 to match main and the other TypeScript examples. Appreciate your help tracking down the version mismatch.

@Laurianti Laurianti Nov 5, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit that moves the example to 26553.5 (8b972f6) is on your branch, but the PR hasn't picked it up: its latest commit is still the merge of main (7caa6e3), and CI hasn't run on the new commit. Pushing to the branch again, even an empty commit, usually makes the PR update.

loki-pr-2247-commits-en

@meysamhadeli

Copy link
Copy Markdown
Author

I checked these on main (c2b3edb) with this PR (8afbc5f) merged. With all the changes suggested below, the example AppHost builds, a gRPC call to loki.Resource.GrpcEndpoint returns grpc-status: 0, and the 25 Loki tests other than the TypeScript one pass with 3.6.19. I didn't run the TypeScript test.

Thanks for testing this and catching both issues! I’ve fixed the gRPC port mismatch and the AppHost build failure. I appreciate the detailed feedback.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 2247

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 2247"

"language": "typescript/nodejs"
},
"sdk": {
"version": "13.6.1"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it will need to be bumped to the 17.0.0 preview because it won't compile the dependencies for the TypeScript tests.

Just double-check the version before committing, as we're doing nightly updates of the packages to ensure we don't have any gaps on the 17 release.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants