I have a asp.net core web app (mvc) project that will write the logs using Serilog to Elasticsearch. I created the index pattern in Kibana and I can view the logs that was written to elasticsearch under Discover. But when I go to Observability -> Logs it shows there are no log messages to display. I go to settings, then under Log indices
I include the index pattern for matching indices that contain log data which for me is customer-simulation-es-app-logs*
and I hit apply. But when I go back to view the logs, nothing will display even after I run the program and write logs to elasticsearch. I can only view the logs in discover but nothing will display in Logs.
Is there a way to fix this issue so I can view the logs that I have written to elasticsearch under logs in Observability?
appsettings.json
{
"ApplicationName": "customer-simulation-es-app",
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
},
"ElasticConfiguration": {
"Uri": "http://localhost:9200"
},
"AllowedHosts": "*"
}
Program.cs
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog((context, configuration) =>
{
configuration.Enrich.FromLogContext()
.Enrich.WithMachineName()
.WriteTo.Console()
.WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri(context.Configuration["ElasticConfiguration:Uri"]))
{
IndexFormat = $"{context.Configuration["ApplicationName"]}-logs-{context.HostingEnvironment.EnvironmentName?.ToLower().Replace(".", "-")}-{DateTime.UtcNow:yyyy-MM}",
AutoRegisterTemplate = true
})
.Enrich.WithProperty("Environment", context.HostingEnvironment.EnvironmentName)
.ReadFrom.Configuration(context.Configuration);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
This is what keeps displaying but there is logs... even if I click on stream live and perform the operations in the app, nothing will get displayed here but in Discover the logs do display. Not sure why I cannot view my logs under Observability -> Logs.
This is the logs in Discover: