Elastic-Cloud Not Receiving Data from Serilog Sink

1.1k Views Asked by At

I set up an Elastic Cloud to offload my local elasticsearch config (as one does), but for reasons unknown to me, I can't get it to show any logs in Elastic Cloud, despite it working fine locally.

The code I got: (modified for privacy reasons)

//var uri = new Uri("http://localhost:9200"); // old one
var uri = new Uri("https://my-server.kb.eastus2.azure.elastic-cloud.com:9243");
var sinkOptions = new ElasticsearchSinkOptions(uri)
{
    AutoRegisterTemplate = true,
    ModifyConnectionSettings = x => x.BasicAuthentication("elastic", "the password I was given"),
    IndexFormat = $"test-logs-{env.EnvironmentName?.ToLower().Replace('.', '-')}-{DateTime.Now:yyyy-MM}",
};

Log.Logger = new LoggerConfiguration()
    .ReadFrom.Configuration(config)
    .Enrich.FromLogContext()
    .Enrich.WithMachineName()
    .WriteTo.Console()
    .WriteTo.Elasticsearch(sinkOptions)
    .Enrich.WithProperty("Environment", env.EnvironmentName)
    .CreateLogger();

There are two possible reasons I can think of that might be the cause of this not working:

  1. The credentials are wrong
  2. The Uri is wrong

Every solution I've been given so far has provided the data in this fashion, and nowhere does it say what the URI I'm supposed to use looks like.

I get no errors.

I get no warnings.

I get no logs.

What am I doing wrong here?

1

There are 1 best solutions below

0
On BEST ANSWER

The issue was using the incorrect uri. I wrote

my-server.kb.eastus2.azure.elastic-cloud.com:9243 rather than
my-server.es.eastus2.azure.elastic-cloud.com:9243.

Note the very tiny difference that is kb vs es in the url