Yesterday I was trying to set minimal privileges for Apikey, so I built a dummy logging application.
I used that application from 10:00-19:00 and then the Elastic search stopped showing logs. Since yesterday 19:00 I am unable to get the any logs from the exact same application.
C# code:
using System;
using Elastic.Ingest.Elasticsearch;
using Elastic.Ingest.Elasticsearch.DataStreams;
using Elastic.Serilog.Sinks;
using Serilog;
using Serilog.Core;
using Serilog.Events;
class Program
{
static async Task Main()
{
var loggerConfig = new LoggerConfiguration()
.MinimumLevel.Verbose()
.WriteTo.Console()
.WriteTo.File("logs/myapp.txt", rollingInterval: RollingInterval.Day);
var apiKey = "SECRET";
loggerConfig.WriteTo.ElasticCloud(
"CLOUD_ID",
apiKey,
opts =>
{
opts.DataStream = new DataStreamName(
"type",
"dataset",
"namespace");
opts.BootstrapMethod = BootstrapMethod.Failure;
opts.MinimumLevel = LogEventLevel.Information;
},
levelSwitch: new LoggingLevelSwitch()
);
Log.Information($"Hello, {apiKey} {DateTime.UtcNow.Second}!");
Log.Error($"Hello, {apiKey} {DateTime.UtcNow.Second}!");
Log.Debug($"Hello, {apiKey} {DateTime.UtcNow.Second}!");
Log.Fatal($"Hello, {apiKey} {DateTime.UtcNow.Second}!");
Log.Warning($"Hello, {apiKey} {DateTime.UtcNow.Second}!");
Log.Information("Hello, world!");
using var l = loggerConfig.CreateLogger();
Log.Logger = l;
var str = "a";
for (int i = 0; i < 1000; i++)
{
str += i;
str += "\n";
}
Log.Information(str);
int a = 10, b = 0;
try
{
Log.Debug("Dividing {A} by {B}", a, b);
Console.WriteLine(a / b);
}
catch (Exception ex)
{
Log.Error(ex, "Something went wrong");
}
finally
{
await Log.CloseAndFlushAsync();
}
}
}
The connection is made between my application and Elasticsearch, since Index template is created, but I cannot display logs on discovery page.