From 97bbb34244e84051bf0dcab08ef5eba239dcd9f2 Mon Sep 17 00:00:00 2001 From: Martijn Laarman Date: Thu, 3 Aug 2023 13:35:33 +0200 Subject: [PATCH] Expose IlmPolicy as option to datashippers (#327) --- .../ElasticsearchLoggerProvider.cs | 2 +- .../Options/ElasticsearchLoggerOptions.cs | 7 +++++++ src/Elastic.Serilog.Sinks/ElasticsearchSink.cs | 9 ++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs b/src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs index 37f1377a..00fe5609 100644 --- a/src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs +++ b/src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs @@ -185,7 +185,7 @@ private IBufferedChannel CreatIngestChannel(ElasticsearchLoggerOptions }; SetupChannelOptions(_channelConfigurations, indexChannelOptions); var channel = new EcsDataStreamChannel(indexChannelOptions); - channel.BootstrapElasticsearch(loggerOptions.BootstrapMethod); + channel.BootstrapElasticsearch(loggerOptions.BootstrapMethod, loggerOptions.IlmPolicy); return channel; } } diff --git a/src/Elastic.Extensions.Logging/Options/ElasticsearchLoggerOptions.cs b/src/Elastic.Extensions.Logging/Options/ElasticsearchLoggerOptions.cs index 69c5fdf6..9656912b 100644 --- a/src/Elastic.Extensions.Logging/Options/ElasticsearchLoggerOptions.cs +++ b/src/Elastic.Extensions.Logging/Options/ElasticsearchLoggerOptions.cs @@ -40,6 +40,13 @@ public class ElasticsearchLoggerOptions : IEcsDocumentCreationOptions /// public BootstrapMethod BootstrapMethod { get; set; } = BootstrapMethod.None; + /// + /// The ILM Policy to apply, see the following for more details: + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html + /// Defaults to `logs` which is shipped by default with Elasticsearch + /// + public string? IlmPolicy { get; set; } + /// /// The index to log into, if this is not set the logger integration will assume it will write into datastreams . /// diff --git a/src/Elastic.Serilog.Sinks/ElasticsearchSink.cs b/src/Elastic.Serilog.Sinks/ElasticsearchSink.cs index 96d8902a..244d49ee 100644 --- a/src/Elastic.Serilog.Sinks/ElasticsearchSink.cs +++ b/src/Elastic.Serilog.Sinks/ElasticsearchSink.cs @@ -60,6 +60,13 @@ public ElasticsearchSinkOptions() : this(new DefaultHttpTransport(TransportHelpe /// public BootstrapMethod BootstrapMethod { get; set; } + /// + /// The ILM Policy to apply, see the following for more details: + /// https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html + /// Defaults to `logs` which is shipped by default with Elasticsearch + /// + public string? IlmPolicy { get; set; } + } /// @@ -90,7 +97,7 @@ public ElasticsearchSink(ElasticsearchSinkOptions options) _channel = new EcsDataStreamChannel(channelOptions, new [] { new SelfLogCallbackListener(options)}); if (_channel.DiagnosticsListener != null) options.ChannelDiagnosticsCallback?.Invoke(_channel.DiagnosticsListener); - _channel.BootstrapElasticsearch(options.BootstrapMethod); + _channel.BootstrapElasticsearch(options.BootstrapMethod, options.IlmPolicy); } ///