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

Try to Connect with ELK Cloud - No Logs Data uploaded

Open LokiLokus opened this issue 3 years ago • 1 comments
trafficstars

Does this issue relate to a new feature or an existing bug?

  • [x] Bug
  • [ ] New Feature

What is the target framework and operating system? See target frameworks & net standard matrix.

  • [x] net5.0
  • [ ] netCore 2.0
  • [ ] netCore 1.0
  • [ ] 4.7
  • [ ] 4.6.x
  • [ ] 4.5.x

Please describe the current behavior? I try to use Elastic to log the logs to the ELK Cloud(Stupid sentence). What I have done so far:

CreateHostBuilder(args)
               .ConfigureLogging(logging =>
               {
                   logging.AddSerilog(new LoggerConfiguration()
                       .Enrich.WithElasticApmCorrelationInfo()
                       .WriteTo.Console(outputTemplate: "[{ElasticApmTraceId} {ElasticApmTransactionId} {Message:lj} {NewLine}{Exception}")
                       .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new CloudConnectionPool("elastic-test:TOKEN",new ApiKeyAuthenticationCredentials("ApiKeyFromELK")))
                       {
                           CustomFormatter = new EcsTextFormatter(),
                           AutoRegisterTemplate = true,
                       })
                       .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("https://elastic-test.apm.westus2.azure.elastic-cloud.com"))
                       {
                           ModifyConnectionSettings = x => x.BasicAuthentication("elastic", "PASSWORD"),
                           CustomFormatter = new EcsTextFormatter(),
                           AutoRegisterTemplate = true,
                       })
                       .CreateLogger());
                   logging.AddAzureWebAppDiagnostics();
                   logging.AddConsole();
               })
               .Build().Run();

Please describe the expected behavior? I wanna see Log data in the cloud, but no data is uploaded. Metric data with UseAllElasticApm works perfectly fine. So how do I configure the logs correctly?

LokiLokus avatar Nov 22 '21 15:11 LokiLokus

I've had a similar issue after upgrading to ESv8.

Apparently a _type argument is specified which happened to be deprecated in ESv7 and became an illegal argument in ESv8. https://www.elastic.co/guide/en/elasticsearch/reference/7.17/removal-of-types.html

Setting ElasticsearchSinkOptions.TypeName = null resolved the issue for me.

6bee avatar Apr 05 '22 15:04 6bee