Kibana version:
7.16.3 (Docker)
Elasticsearch version:
7.16.3 (Docker)
APM Server version:
7.16.3 (Docker)
APM Agent language and version:
.net
<PackageReference Include="Elastic.Apm.NetCoreAll" Version="1.16.1" />
<PackageReference Include="Elastic.Apm.SerilogEnricher" Version="1.5.3" />
<PackageReference Include="Elastic.Apm.StackExchange.Redis" Version="1.16.1" />
Description of the problem including expected versus actual behavior. Please include screenshots (if relevant):
Hi,
I use correlated transactions across multiple microservices (.net 6) using the .net APM agent, it works pretty well.
My problem is about logs, I don't know why the Service Name does not appear, so that I'm not able to distinguish which log belongs to which microservice.
Example here is an example of a correlated transaction
and the corresponding logs, but with an empty Service Name column
My Serilog logger instance is built this way :
public static Logger GetELKLogger(IConfiguration config, string varEnv = "ElasticSearchLog")
{
var configuration = config.Get<Configuration>(varEnv);
return new LoggerConfiguration()
.ReadFrom.Configuration(config)
.Enrich.WithElasticApmCorrelationInfo()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(configuration.ElasticSearchLog))
{
AutoRegisterTemplate = true,
IndexFormat = "mslogs-{0:yyyy.MM.dd}",
DetectElasticsearchVersion = true,
RegisterTemplateFailure = RegisterTemplateRecovery.IndexAnyway,
AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,
FailureCallback = e => Console.WriteLine($"Unable to submit event {e?.RenderMessage()} to ElasticSearch. Exception : " + e?.Exception?.ToString()),
EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog |
EmitEventFailureHandling.WriteToFailureSink |
EmitEventFailureHandling.RaiseCallback,
BufferCleanPayload = (failingEvent, statuscode, exception) =>
{
dynamic e = JObject.Parse(failingEvent);
return JsonConvert.SerializeObject(new Dictionary<string, object>()
{
{ "action", "DeniedByElasticSearch"},
{ "@timestamp",e["@timestamp"]},
{ "level","Error"},
{ "message","Error: "+e.message},
{ "messageTemplate",e.messageTemplate},
{ "failingStatusCode", statuscode},
{ "failingException", exception}
});
},
CustomFormatter = new EcsTextFormatter()
})
.CreateLogger();
}
My minimal appsettings.json for each Microservice is
"Serilog": {
"Using": [],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"System": "Information",
"Elastic": "Warning",
"Apm": "Warning"
}
},
"WriteTo": [
{
"Name": "Console"
}
],
"Enrich": [
"FromLogContext",
"WithMachineName",
"WithProcessId",
"WithThreadId"
],
"Properties": {
"ApplicationName": "IT.Microservices.AbandonedCartEmailSender"
}
},
"ElasticApm": {
"ServerUrl":"http://apm:8200",
"Enabled": true,
"TransactionSampleRate": 1,
"CaptureBody": "all",
"CaptureHeaders": true,
"SpanFramesMinDuration": 0, // no stacktrace except for exception
"CloudProvider": "none"
},
"ElasticSearchLog": {
"ElasticSearchLog": "http://elasticsearch:9200/"
}
What did I miss to have the Service Name in APM ?