Skip to content

Commit 97bbb34

Browse files
authored
Expose IlmPolicy as option to datashippers (#327)
1 parent fbc1c52 commit 97bbb34

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/Elastic.Extensions.Logging/ElasticsearchLoggerProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private IBufferedChannel<LogEvent> CreatIngestChannel(ElasticsearchLoggerOptions
185185
};
186186
SetupChannelOptions(_channelConfigurations, indexChannelOptions);
187187
var channel = new EcsDataStreamChannel<LogEvent>(indexChannelOptions);
188-
channel.BootstrapElasticsearch(loggerOptions.BootstrapMethod);
188+
channel.BootstrapElasticsearch(loggerOptions.BootstrapMethod, loggerOptions.IlmPolicy);
189189
return channel;
190190
}
191191
}

src/Elastic.Extensions.Logging/Options/ElasticsearchLoggerOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ public class ElasticsearchLoggerOptions : IEcsDocumentCreationOptions
4040
/// </summary>
4141
public BootstrapMethod BootstrapMethod { get; set; } = BootstrapMethod.None;
4242

43+
/// <summary>
44+
/// The ILM Policy to apply, see the following for more details:
45+
/// <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html</para>
46+
/// Defaults to `logs` which is shipped by default with Elasticsearch
47+
/// </summary>
48+
public string? IlmPolicy { get; set; }
49+
4350
/// <summary>
4451
/// The index to log into, if this is not set the logger integration will assume it will write into datastreams <see cref="DataStream"/>.
4552
/// <para>

src/Elastic.Serilog.Sinks/ElasticsearchSink.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ public ElasticsearchSinkOptions() : this(new DefaultHttpTransport(TransportHelpe
6060
/// <inheritdoc cref="BootstrapMethod"/>
6161
public BootstrapMethod BootstrapMethod { get; set; }
6262

63+
/// <summary>
64+
/// The ILM Policy to apply, see the following for more details:
65+
/// <para>https://www.elastic.co/guide/en/elasticsearch/reference/current/index-lifecycle-management.html</para>
66+
/// Defaults to `logs` which is shipped by default with Elasticsearch
67+
/// </summary>
68+
public string? IlmPolicy { get; set; }
69+
6370
}
6471

6572
/// <summary>
@@ -90,7 +97,7 @@ public ElasticsearchSink(ElasticsearchSinkOptions<TEcsDocument> options)
9097
_channel = new EcsDataStreamChannel<TEcsDocument>(channelOptions, new [] { new SelfLogCallbackListener<TEcsDocument>(options)});
9198
if (_channel.DiagnosticsListener != null)
9299
options.ChannelDiagnosticsCallback?.Invoke(_channel.DiagnosticsListener);
93-
_channel.BootstrapElasticsearch(options.BootstrapMethod);
100+
_channel.BootstrapElasticsearch(options.BootstrapMethod, options.IlmPolicy);
94101
}
95102

96103
/// <inheritdoc cref="ILogEventSink.Emit"/>

0 commit comments

Comments
 (0)