How to add Elasticsearch Service correlation with Serilog

Viewed 255

I am monitoring my application using Elasticsearch's APM. This application includes several nodes, each with their own Elasticsearch service.

For now, Elasticsearch is able to correlate logs with transactions and spans created inside our application, but they do not correlate with the service or node that created them.

Whenever I go to Service > Logs, this shows up.

I noticed that the field "Service Name" is empty in the transaction logs.

Here's how I'm configuring my application's Serilog:

    private static readonly Serilog.Core.Logger Serilogger = new LoggerConfiguration()
        .Enrich.WithProperty("ApplicationName", "myApp")
        .Enrich.FromLogContext()
        .WriteTo.Console()
        .Enrich.WithElasticApmCorrelationInfo()
        .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri($"http://{StaticAddresses.ElasticIp}:{StaticAddresses.ElasticHttpPort}"))
        {
            CustomFormatter = new EcsTextFormatter(),
            AutoRegisterTemplate = true,
            IndexFormat = "myApp",
            ModifyConnectionSettings = x => x.BasicAuthentication(ApmConfiguration.ElasticUser, ApmConfiguration.ElasticPswd)
        })
        .CreateLogger();

Is there any way I can add a field including the Service Name here? Am I missing something?

1 Answers
Related