Table of Contents

Class ElasticsearchHealthMonitor

Namespace
Excalibur.Data.ElasticSearch.Monitoring
Assembly
Excalibur.Data.ElasticSearch.dll

Provides comprehensive health monitoring for Elasticsearch cluster and individual nodes with background polling.

public sealed class ElasticsearchHealthMonitor : BackgroundService, IHostedService, IDisposable
Inheritance
ElasticsearchHealthMonitor
Implements
Inherited Members

Remarks

Initializes a new instance of the ElasticsearchHealthMonitor class.

Constructors

ElasticsearchHealthMonitor(ElasticsearchClient, ElasticsearchMetrics, ILogger<ElasticsearchHealthMonitor>, IOptions<ElasticsearchMonitoringOptions>)

Provides comprehensive health monitoring for Elasticsearch cluster and individual nodes with background polling.

public ElasticsearchHealthMonitor(ElasticsearchClient client, ElasticsearchMetrics metrics, ILogger<ElasticsearchHealthMonitor> logger, IOptions<ElasticsearchMonitoringOptions> options)

Parameters

client ElasticsearchClient

The Elasticsearch client for health checks.

metrics ElasticsearchMetrics

The metrics collector for health status.

logger ILogger<ElasticsearchHealthMonitor>

The logger for health monitoring.

options IOptions<ElasticsearchMonitoringOptions>

The monitoring configuration options.

Remarks

Initializes a new instance of the ElasticsearchHealthMonitor class.

Properties

LastClusterHealth

Gets the last known cluster health information.

public ElasticsearchClusterHealth? LastClusterHealth { get; }

Property Value

ElasticsearchClusterHealth

The last known cluster health information.

LastHealthCheckTime

Gets the timestamp of the last health check.

public DateTimeOffset LastHealthCheckTime { get; }

Property Value

DateTimeOffset

The timestamp of the last health check.

Methods

CheckHealthAsync(CancellationToken)

Performs an immediate health check of the Elasticsearch cluster.

public Task<ElasticsearchClusterHealth> CheckHealthAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<ElasticsearchClusterHealth>

A task representing the health check operation with cluster health information.

ExecuteAsync(CancellationToken)

This method is called when the IHostedService starts. The implementation should return a task that represents the lifetime of the long running operation(s) being performed.

protected override Task ExecuteAsync(CancellationToken stoppingToken)

Parameters

stoppingToken CancellationToken

Triggered when StopAsync(CancellationToken) is called.

Returns

Task

A Task that represents the long running operations.

Remarks

See Worker Services in .NET for implementation guidelines.

GetNodeHealthStatus()

Gets the current health status of all monitored nodes.

public IReadOnlyDictionary<string, NodeHealthInfo> GetNodeHealthStatus()

Returns

IReadOnlyDictionary<string, NodeHealthInfo>

A dictionary of node IDs and their health information.