I have switched from Serilog.Sinks.Elasticsearch package to Elastic.Serilog.Sinks. Before I would specify target index name like this:
string indexFormat = settings.IndexName;
configuration
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(settings.ConnectionString))
{
MinimumLogEventLevel = logLevel.Value,
AutoRegisterTemplate = true,
IndexFormat = indexFormat, // this worked just fine
BatchAction = ElasticOpType.Create
});
}
This would send logs to the expected index 'qa-stem-backend-log'.
After switching to the Elastic.Serilog.Sinks I scaffold things like this:
string indexFormat = settings.IndexName;
configuration.WriteTo.Elasticsearch([new Uri(settings.ConnectionString)], options =>
{
options.LevelSwitch = new()
{
MinimumLevel = logLevel.Value,
};
options.DataStream = new DataStreamName(indexFormat); // I set index name here
options.TextFormatting = new EcsTextFormatterConfiguration();
options.BootstrapMethod = BootstrapMethod.Failure;
options.ConfigureChannel = channelOptions =>
{
channelOptions.BufferOptions = new BufferOptions();
};
});
However instead of writing to the existing and well known 'qa-stem-backend-log' index it went to create it's own .ds-qa-stem-backend-log-generic-default-2025.01.15-000001. How to force it to write logs to the existing 'qa-stem-backend-log' and not create any new (and hidden) indexes?