Skip to content

Hosting Guide ​

CritterWatch supports several hosting topologies. Choose based on your team's needs and infrastructure constraints.

The most common production topology. CritterWatch runs as its own dedicated web application, separate from the services it monitors.

Advantages:

  • Clear separation of concerns
  • Isolated failure domain — if CritterWatch crashes, monitored services are unaffected
  • Independently scalable and deployable
  • Simpler security boundary
cs
// Program.cs
var builder = WebApplication.CreateBuilder(args);

builder.AddCritterWatch(
    builder.Configuration.GetConnectionString("critterwatch")!,
    opts =>
    {
        opts.UseRabbitMq(new Uri(builder.Configuration.GetConnectionString("rabbitmq")!))
            .AutoProvision();
        opts.ListenToRabbitQueue("critterwatch").ProcessInParallelWithNativeAcks().UseCritterWatchSerializer();
    });

var app = builder.Build();
app.UseCritterWatch();
app.Run();

The embedded Vue SPA is served from the server's root path. Navigate to https://your-critterwatch-host/ to open the console.

Embedded in Your Application ​

New in 1.1, the console can also run inside an existing Wolverine application instead of as its own process: opts.AddCritterWatchEmbedded(...) inside UseWolverine(), and app.UseCritterWatchEmbedded() to mount the UI under /critterwatch. It monitors that one application and nothing else, keeps its data in a store of its own, and runs single-instance only. It is aimed at the development inner loop; on SQLite it needs no infrastructure at all. See Embedded CritterWatch.

.NET Aspire Orchestration ​

For development and staging, add the CritterWatch.Aspire package to your AppHost:

bash
dotnet add package CritterWatch.Aspire

First published after 1.1.0-rc.3

CritterWatch.Aspire is published from the release after 1.1.0-rc.3. It was built as Aspire.Hosting.CritterWatch, but Aspire.Hosting.* is a reserved package-id prefix on nuget.org, so it was renamed before its first publish. Its API is unchanged, and its extension methods stay in the Aspire.Hosting namespace, like every other Aspire integration.

The console is your own project, the standalone host above, so the AppHost adds that project. AddCritterWatch<TProject>() is AddProject<TProject>() plus an "Open console" link and a health check on the console's liveness route, /health/live. Anything that WaitFors the console therefore waits for one that is serving, not just one whose process has started.

cs
var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres");
// Not "critterwatch": Aspire resource names are unique across types, and the console owns that one.
var critterStore = postgres.AddDatabase("critterstore", "critterwatch");
var rabbit = builder.AddRabbitMQ("rabbitmq");

// Your console project: the ASP.NET Core app that calls builder.AddCritterWatch(...) and app.UseCritterWatch().
var console = builder.AddCritterWatch<Projects.MyCritterWatchConsole>()
    // connectionName makes it ConnectionStrings:critterwatch, which is what the console reads
    .WithReference(critterStore, connectionName: "critterwatch").WaitFor(critterStore)
    .WithReference(rabbit).WaitFor(rabbit)
    .WithJasperFxLicense();

// A monitored service waits for a healthy console and receives the console's license.
builder.AddProject<Projects.TripService>("trip-service")
    .WithReference(postgres).WaitFor(postgres)
    .WithReference(rabbit).WaitFor(rabbit)
    .WithCritterWatch(console);

builder.Build().Run();

What each call does:

calleffect
AddCritterWatch<TProject>()adds your console project (named critterwatch by default) with an "Open console" link and a health check on /health/live
WithCritterWatch(console)the service waits for the console to be healthy, gets a service-discovery reference to it, and receives the console's license
WithJasperFxLicense()the AppHost's JasperFx:LicenseKey as a secret parameter; a no-op when the AppHost has none, so a fleet without a key still boots
WithJasperFxLicense(parameter)an explicit parameter instead, such as builder.AddParameter("jasperfx-license", secret: true)
WithCritterWatchMcp()tells Aspire's tooling the console serves MCP at /api/mcp; only for a console that calls MapCritterWatchMcp() (experimental, ASPIREMCP001)
WithCritterWatchMcp(readOnly: true)the same, and sets CritterWatch:Mcp:ReadOnly on the console so its MCP server registers only the read tools; it can turn read-only on, never off. See MCP › Read-only

Why the license has to reach the monitored services

Pause, rebuild, replay and the other licensed operator commands execute on the monitored service, not on the console. Aspire's child processes do not inherit the AppHost's environment, so without WithJasperFxLicense() they run unlicensed and refuse those commands. In the AppHost, the JASPERFX__LICENSEKEY environment variable is the configuration key JasperFx:LicenseKey: the environment-variable provider turns __ into :, so Configuration["JASPERFX__LICENSEKEY"] is always null.

WithCritterWatch does not configure the monitoring link itself. Each service names the console's endpoint in its own AddCritterWatchMonitoring(...) call, and the client reads no configuration key for it.

This repository's own AppHost (src/BffHost) is a development harness, not a template. Its fleet runs against the docker-compose containers the test suites share, and it serves the console from a Vite dev server. A console built from the packages serves its embedded SPA itself.

Building the NuGet Package with Embedded Frontend ​

The packages on nuget.org already contain the SPA; this section applies only when you pack a console package from source. When publishing the CritterWatch NuGet package (or CritterWatch.SqlServer / CritterWatch.Sqlite, or distributing as a private package), build with the EmbedFrontend property to bundle the Vue SPA:

bash
dotnet pack src/CritterWatch -p:EmbedFrontend=true

Or for a regular build:

bash
dotnet build src/CritterWatch -p:EmbedFrontend=true

Without -p:EmbedFrontend=true, the frontend is not embedded — it must be served by a separate dev server (the Aspire configuration handles this automatically).

Production Considerations ​

HTTPS ​

Always serve CritterWatch over HTTPS in production. CritterWatch gives operators significant control over your services — plaintext communication is a security risk.

cs
// Enforce HTTPS redirection
app.UseHttpsRedirection();
app.UseHsts();
app.UseCritterWatch();

Authentication ​

CritterWatch does not ship with built-in authentication. Add ASP.NET Core authentication middleware before UseCritterWatch():

cs
// Register authentication/authorization BEFORE UseCritterWatch so every
// CritterWatch endpoint — its HTTP API and the SignalR hub it maps
// internally — sits behind your auth middleware.
app.UseAuthentication();
app.UseAuthorization();

app.UseCritterWatch();

Network Isolation ​

In production, CritterWatch should not be publicly accessible. Place it behind a VPN, internal load balancer, or IP allowlist. The transport (RabbitMQ) connecting CritterWatch to your services should also be on an internal network.

Scaling ​

CritterWatch runs single-node by default — no extra configuration needed for small deployments, and cluster partitioning stays off until you supply a sharded topology. For horizontal scaling, the console supports a clustered topology (2+ BFF nodes behind a load balancer): per-service partitioning prevents two nodes from processing the same service's updates concurrently, agent families distributed by Wolverine's node coordination run each alert evaluator, retention sweep and metrics scraper on exactly one node, moving it to a surviving node on failover, and a Redis SignalR backplane fans push messages to every connected browser regardless of which node owns the WebSocket. See Clustering for the full topology, the opt-in configuration, and the trade-offs.

For single-node deployments — the default — use a process manager (systemd, Kubernetes) to restart CritterWatch automatically on failure.

Health Checks ​

UseCritterWatch() already maps the console's own probes: /health/live (liveness, 503 only when a restart is the right response) and /health/ready (readiness, every CritterWatch check). Point your orchestrator at those, not at /, which serves the SPA shell and answers 200 regardless. See Probing the CritterWatch console itself and the CritterWatch:Liveness settings there.

To add checks of your own, such as database connectivity, register them as usual:

csharp
builder.Services.AddHealthChecks()
    .AddNpgSql(connectionString, name: "critterwatch-db");

app.MapHealthChecks("/health");