Skip to content

Commit

Permalink
Expose IlmPolicy as option to datashippers (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mpdreamz authored Aug 3, 2023
1 parent fbc1c52 commit 97bbb34
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private IBufferedChannel<LogEvent> CreatIngestChannel(ElasticsearchLoggerOptions
};
SetupChannelOptions(_channelConfigurations, indexChannelOptions);
var channel = new EcsDataStreamChannel<LogEvent>(indexChannelOptions);
channel.BootstrapElasticsearch(loggerOptions.BootstrapMethod);
channel.BootstrapElasticsearch(loggerOptions.BootstrapMethod, loggerOptions.IlmPolicy);
return channel;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public class ElasticsearchLoggerOptions : IEcsDocumentCreationOptions
/// </summary>
public BootstrapMethod BootstrapMethod { get; set; } = BootstrapMethod.None;

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

/// <summary>
/// The index to log into, if this is not set the logger integration will assume it will write into datastreams <see cref="DataStream"/>.
/// <para>
Expand Down
9 changes: 8 additions & 1 deletion src/Elastic.Serilog.Sinks/ElasticsearchSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ public ElasticsearchSinkOptions() : this(new DefaultHttpTransport(TransportHelpe
/// <inheritdoc cref="BootstrapMethod"/>
public BootstrapMethod BootstrapMethod { get; set; }

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

}

/// <summary>
Expand Down Expand Up @@ -90,7 +97,7 @@ public ElasticsearchSink(ElasticsearchSinkOptions<TEcsDocument> options)
_channel = new EcsDataStreamChannel<TEcsDocument>(channelOptions, new [] { new SelfLogCallbackListener<TEcsDocument>(options)});
if (_channel.DiagnosticsListener != null)
options.ChannelDiagnosticsCallback?.Invoke(_channel.DiagnosticsListener);
_channel.BootstrapElasticsearch(options.BootstrapMethod);
_channel.BootstrapElasticsearch(options.BootstrapMethod, options.IlmPolicy);
}

/// <inheritdoc cref="ILogEventSink.Emit"/>
Expand Down

0 comments on commit 97bbb34

Please sign in to comment.