serilog-sinks-elasticsearch icon indicating copy to clipboard operation
serilog-sinks-elasticsearch copied to clipboard

[Question] Is there a way to configure ElasticsearchSinkOptions for role-based authentication?

Open joaco-espinosa opened this issue 4 years ago • 1 comments
trafficstars

The only way I've been able to utilize the library relies on provisioning either username/pwd or an API Key.

Is there a way I can avoid providing this data, considering that my code is running on an EC2 instance that has a role with the proper permissions to write to Elasticsearch?

I've tried the following code but can't get the extension to log to Elasticsearch (i.e. I continue to see all logs in a database table that is configured as a FailureSink):

return new ElasticsearchSinkOptions(new Uri(configuration["Configuration:Uri"]))
{
    FailureCallback = e => Console.WriteLine(Errors.ElasticSearch.ConnectionError(configuration["Configuration:Uri"])),
    EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog |
                       EmitEventFailureHandling.WriteToFailureSink |
                       EmitEventFailureHandling.RaiseCallback,
    FailureSink = new MSSqlServerSink(serilogConnString, "Log", 30, TimeSpan.FromMinutes(1), null, true, new ColumnOptions(), "dbo"),
    MinimumLogEventLevel = Enum.Parse<LogEventLevel>(configuration["Configuration:MinimumLevel"]),
    AutoRegisterTemplate = true,
    IndexFormat = LogConstants.IndexName
};

Thanks in advance.

joaco-espinosa avatar Jun 16 '21 17:06 joaco-espinosa

?

joaco-espinosa avatar Jul 02 '21 17:07 joaco-espinosa