Seq integration
이 콘텐츠는 아직 번역되지 않았습니다.
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.
Hosting integration
Section titled “Hosting integration”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 add seqAspire CLI는 대화형입니다. 프롬프트 시 알맞은 검색 결과 선택:
Select an integration to add:
> seq (Aspire.Hosting.Seq)> Other results listed as selectable options...#:package Aspire.Hosting.Seq@*<PackageReference Include="Aspire.Hosting.Seq" Version="*" />Add a Seq resource
Section titled “Add a Seq resource”In your AppHost project, call AddSeq to add and return a Seq resource builder:
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 in the Aspire manifest
Section titled “Seq in the Aspire manifest”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.
Persistent logs and traces
Section titled “Persistent logs and traces”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.
Add a Seq resource with a data volume
Section titled “Add a Seq resource with a data volume”To add a data volume to the Seq resource, call the WithDataVolume method:
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.
Connection properties
Section titled “Connection properties”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 Name | Description |
|---|---|
Host | The hostname or IP address of the Seq server |
Port | The port number the Seq server is listening on |
Uri | The connection URI, with the format http://{Host}:{Port} |
Example connection string:
Uri: http://localhost:5341Client integration
Section titled “Client integration”To get started with the Seq client integration, install the 📦 Aspire.Seq NuGet package in the client-consuming project:
dotnet add package Aspire.Seq#:package Aspire.Seq@*<PackageReference Include="Aspire.Seq" Version="*" />Add a Seq client
Section titled “Add a Seq client”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");Configuration
Section titled “Configuration”The Seq integration provides multiple options to configure the connection to Seq.
Use configuration providers
Section titled “Use configuration providers”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" } }}Use named configuration
Section titled “Use named configuration”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");Use inline delegates
Section titled “Use inline delegates”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";});Client integration health checks
Section titled “Client integration health checks”By default, Aspire integrations enable health checks for all services. The Seq integration:
- Adds the health check when
DisableHealthChecksisfalse, which attempts to connect to the Seq server’s/healthendpoint. - Integrates with the
/healthHTTP endpoint.
Observability and telemetry
Section titled “Observability and telemetry”Logging
Section titled “Logging”The Seq integration uses the following log categories:
Seq
Tracing and Metrics
Section titled “Tracing and Metrics”The Seq integration doesn’t emit tracing activities or metrics because it’s a telemetry sink, not a telemetry source.