コンテンツにスキップ

Seq integration

このコンテンツはまだ日本語訳がありません。

Seq logo

Seq is the intelligent search, analysis, and alerting server built for structured log data. The Aspire Seq integration enables you to connect to existing Seq instances or create new instances from Aspire with the datalust/seq container image.

The Seq hosting integration models a Seq resource as the SeqResource type. To access this type and APIs, add the 📦 Aspire.Hosting.Seq NuGet package in your AppHost project:

Aspire CLI — Aspire.Hosting.Seq パッケージを追加
aspire add seq

Aspire CLI は対話的です。求められたら適切な結果を選択してください:

Aspire CLI — 出力例
Select an integration to add:
> seq (Aspire.Hosting.Seq)
> Other results listed as selectable options...

In your AppHost project, call AddSeq to add and return a Seq resource builder:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var seq = builder.AddSeq("seq")
.ExcludeFromManifest()
.WithLifetime(ContainerLifetime.Persistent)
.WithEnvironment("ACCEPT_EULA", "Y");
var myService = builder.AddProject<Projects.ExampleProject>()
.WithReference(seq)
.WaitFor(seq);

Accept the Seq End User License Agreement (EULA)

Section titled “Accept the Seq End User License Agreement (EULA)”

You must accept the Seq EULA for Seq to start. To accept the agreement in code, pass the environment variable ACCEPT_EULA to the Seq container, and set its value to Y.

Seq shouldn’t be part of the Aspire deployment manifest, hence the chained call to ExcludeFromManifest. It’s recommended you set up a secure production Seq server outside of Aspire for your production environment.

Register Seq with a data directory in your AppHost project to retain Seq’s data and configuration across application restarts:

var seq = builder.AddSeq("seq", seqDataDirectory: "./seqdata")
.ExcludeFromManifest()
.WithLifetime(ContainerLifetime.Persistent);

The directory specified must already exist.

To add a data volume to the Seq resource, call the WithDataVolume method:

C# — AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);
var seq = builder.AddSeq("seq")
.WithDataVolume()
.ExcludeFromManifest()
.WithLifetime(ContainerLifetime.Persistent);
var myService = builder.AddProject<Projects.ExampleProject>()
.WithReference(seq)
.WaitFor(seq);

The data volume is used to persist the Seq data outside the lifecycle of its container.

When you reference a Seq resource using WithReference, the following connection properties are made available to the consuming project:

The Seq resource exposes the following connection properties:

Property NameDescription
HostThe hostname or IP address of the Seq server
PortThe port number the Seq server is listening on
UriThe connection URI, with the format http://{Host}:{Port}

Example connection string:

Uri: http://localhost:5341

To get started with the Seq client integration, install the 📦 Aspire.Seq NuGet package in the client-consuming project:

.NET CLI — Add Aspire.Seq package
dotnet add package Aspire.Seq

In the Program.cs file of your client-consuming project, call the AddSeqEndpoint extension method to register OpenTelemetry Protocol exporters to send logs and traces to Seq:

builder.AddSeqEndpoint(connectionName: "seq");

The Seq integration provides multiple options to configure the connection to Seq.

The Seq integration supports Microsoft.Extensions.Configuration. It loads the SeqSettings from configuration using the Aspire:Seq key. Example appsettings.json:

{
"Aspire": {
"Seq": {
"DisableHealthChecks": true,
"ServerUrl": "http://localhost:5341"
}
}
}

The Seq integration supports named configuration for multiple instances:

{
"Aspire": {
"Seq": {
"seq1": {
"ServerUrl": "http://seq1:5341",
"DisableHealthChecks": true
},
"seq2": {
"ServerUrl": "http://seq2:5341",
"DisableHealthChecks": false
}
}
}
}

Use the connection names when calling AddSeqEndpoint:

builder.AddSeqEndpoint("seq1");
builder.AddSeqEndpoint("seq2");

You can pass the Action<SeqSettings> delegate to set up options inline:

builder.AddSeqEndpoint("seq", static settings =>
{
settings.DisableHealthChecks = true;
settings.ServerUrl = "http://localhost:5341";
});

By default, Aspire integrations enable health checks for all services. The Seq integration:

  • Adds the health check when DisableHealthChecks is false, which attempts to connect to the Seq server’s /health endpoint.
  • Integrates with the /health HTTP endpoint.

The Seq integration uses the following log categories:

  • Seq

The Seq integration doesn’t emit tracing activities or metrics because it’s a telemetry sink, not a telemetry source.

質問 & 回答コラボレーションコミュニティディスカッション視聴