Skip to content
This repository has been archived by the owner on Jun 1, 2024. It is now read-only.

Unsuccessful product check call ElasticSearch #512

Open
6 tasks
goforebroke opened this issue Feb 11, 2023 · 2 comments
Open
6 tasks

Unsuccessful product check call ElasticSearch #512

goforebroke opened this issue Feb 11, 2023 · 2 comments

Comments

@goforebroke
Copy link

goforebroke commented Feb 11, 2023

Does this issue relate to a new feature or an existing bug?

  • [ X] Bug
  • New Feature

What version of Serilog.Sinks.Elasticsearch is affected? Please list the related NuGet package.

Serilog.Sinks.Elasticsearch 9.0

What is the target framework and operating system? See target frameworks & net standard matrix.

.Net 7

  • netCore 2.0
  • netCore 1.0
  • 4.7
  • 4.6.x
  • 4.5.x

Please describe the current behavior?

My application consists of the following components

.Net 7
Docker Desktop

I am using ElasticSearch 8.6.1 and Serilog.Sinks.Elasticsearch 9.0

docker compose configuration

 elasticsearch:
    container_name: elasticsearch
    environment:
        - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
        - xpack.security.enabled=false
        - discovery.type=single-node
        - "ELASTIC_CLIENT_APIVERSIONING=true"
    restart: always
    ports:
        - "9200:9200"
        - "9300:9300"
    networks:
        - my-network

  kibana:
    container_name: kibana
    restart: always
    environment:
        - ELASTICSEARCH_HOSTS=http://elasticsearch:9200
    depends_on:
        - elasticsearch
    ports:
        - "5601:5601"
    networks:
        - my-network

My projects all use a common library for logging. Here is a snippet of the code in the library that sets up logging to ES

public static class SeriLogger
  {
      public static Action<HostBuilderContext, LoggerConfiguration> Configure =>
        (context, configuration) =>
        {
            var settings = new ElasticConfigurationSettings();
            context.Configuration.GetSection("ElasticConfiguration").Bind(settings);

            configuration
                 .Enrich.FromLogContext()
                 .Enrich.WithMachineName()
                 .WriteTo.Debug()
                 .WriteTo.Console()
                 .WriteTo.Elasticsearch(
                     new ElasticsearchSinkOptions(new Uri(settings.Uri))
                     {
                         IndexFormat = $"applogs-{context.HostingEnvironment.ApplicationName?.ToLower().Replace(".", "-")}-{context.HostingEnvironment.EnvironmentName?.ToLower().Replace(".", "-")}-{DateTime.UtcNow:yyyy-MM}",
                         AutoRegisterTemplate = true,
                         OverwriteTemplate = true,
                         TemplateName = "Test Template",
                         AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7,
                         TypeName = null,
                         BatchAction = ElasticOpType.Create
                     })
                 .Enrich.WithProperty("Environment", context.HostingEnvironment.EnvironmentName ?? "Environment Missing")
                 .Enrich.WithProperty("Application", context.HostingEnvironment.ApplicationName ?? "Application Unknown")
                 .ReadFrom.Configuration(context.Configuration);
                 SelfLog.Enable(Console.Error);
        };
  }

AppSettings for the different areas of the application

  "ElasticConfiguration": {
    "Uri": "http://elasticsearch:9200"
  }

Upon starting up the application, I get and error stating "Unsuccessful product check call" .
The errors don't prevent me from sending/saving logging data to ES, so I don't understand why I am getting the error at startup

My Web front end and API's all have ES as a dependency

depends_on:
  - rabbitmq
  - tenantstore.grpc
  - elasticsearch

I get an error upon running the application with docker compose

Caught exception while performing bulk operation to Elasticsearch: Elasticsearch.Net.ElasticsearchClientException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product. Call: Status code unknown from: GET /
---> Elasticsearch.Net.PipelineException: The client is unable to verify that the server is Elasticsearch due to an unsuccessful product check call. Some functionality may not be compatible if the server is running an unsupported product.
---> System.Net.Http.HttpRequestException: An error occurred while sending the request.
---> System.IO.IOException: The response ended prematurely.

Please describe the expected behavior?

Application should start without any errors logged to console

If the current behavior is a bug, please provide the steps to reproduce the issue and if possible a minimal demo of the problem

I am not sure if its a bug or something I have misconfigured on my end. Any help appreciated.

@mivano
Copy link
Contributor

mivano commented Feb 13, 2023

Does that only happen when you talk to the container version of ES, or also to ES running somewhere else?

It looks like it is coming from the underlying ES client library. @nenadvicentic any clue?

@nenadvicentic
Copy link
Contributor

I've looked briefly through the ES client code. I think code comment bellow explains what happens:

// Any response besides a 200, 401 or 403 is considered a failure and the check is considered incomplete and marked as a likely transient failure.
// This means that the check will run on subsequent requests until we have a valid response to evaluate.
// By returning false, the failure to perform the product check will be included in the audit log.
if (!response.Success)
{
	_connectionPool.ProductCheckStatus = ProductCheckStatus.TransientFailure;
	return false;
}

This is the source code lines, as it was in Elasticsearch.NET client version 7.17.5. So, most likely some kind of redirect, file-not-changed or something similar being issued by ES server or docker's port-forwarding logic. I think this issue has nothing to do with Serilog.Sinks.Elasticsearch v9.0.0.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants