Search code examples
elasticsearch

How to determine if ElasticSearch Url and Credentials are correct


I am currently trying to send logs directly to elastic search via serilog event sink. Unfortunately this fails and I believe it's because of the credentials I was provided but I am unsure how to verify this.

https://xxxx.aws.found.io:9243

username : xxxx password : yyyy

builder.Host.UseSerilog((ctx, configuration) =>
{
    configuration.ReadFrom.Configuration(ctx.Configuration)
     .WriteTo.Elasticsearch(new ElasticsearchSinkOptions(new Uri("https://xxxxxx.aws.found.io:9243"))
     {
         IndexFormat = "logs-ea.standard-{0:yyyy.MM}",
         FailureCallback = e => Console.WriteLine("Unable to submit event " + JsonSerializer.Serialize(e)),
         EmitEventFailure = EmitEventFailureHandling.WriteToSelfLog |
                            EmitEventFailureHandling.WriteToFailureSink |
                            EmitEventFailureHandling.RaiseCallback,
         ModifyConnectionSettings = x => x.BasicAuthentication("xxxxx", "yyyyy")

     });
});

I can login to that uri fine with the credentials provided. It looks like below enter image description here

When I log in, I am brought to the screen below where I can choose a space. Is this actually elastic search? enter image description here

My hunch is, I think it might be related to the uri though as the port isn't 9200 but I am told that's the correct url. If I may get some further assistance on how to validate if the elastic search uri and credentials are correct.


Solution

  • es_url: https://xxxx.aws.found.io:9243
    username: xxxx
    password: yyyy
    

    You can try to curl Elasticsearch to check your credentials.

    curl -ks "https://xxxx.aws.found.io:9243" -u "xxxx:yyyy"
    

    also you can enable the verbose mode with -v and debug it.