dotnet-cqrs/docs/observability/health-checks/health-thresholds.md

45 lines
1.0 KiB
Markdown

# Health Thresholds
Configure thresholds for degraded and unhealthy states.
## Threshold Configuration
```csharp
builder.Services.AddStreamHealthChecks(options =>
{
// Consumer lag thresholds
options.DegradedConsumerLagThreshold = 1000;
options.UnhealthyConsumerLagThreshold = 10000;
// Stall detection
options.DegradedStalledThreshold = TimeSpan.FromMinutes(5);
options.UnhealthyStalledThreshold = TimeSpan.FromMinutes(15);
// Error rates
options.DegradedErrorRate = 5; // errors/min
options.UnhealthyErrorRate = 10; // errors/min
});
```
## Environment-Specific Thresholds
```csharp
var thresholds = builder.Environment.IsProduction()
? new HealthCheckOptions
{
DegradedConsumerLagThreshold = 10000,
UnhealthyConsumerLagThreshold = 100000
}
: new HealthCheckOptions
{
DegradedConsumerLagThreshold = 100,
UnhealthyConsumerLagThreshold = 1000
};
builder.Services.AddStreamHealthChecks(thresholds);
```
## See Also
- [Health Checks Overview](README.md)