markmcdowell/NLog.Targets.ElasticSearch

High disponibility need to suport connectionTimeout, maxRetries, retryDelayTime and throwExceptions

Yaume2 opened this issue · 1 comments

Yaume2 commented

I have a resilience problem. Indeed, when the ElasticSearch service is down, the application blocks. It chains blocking calls. As a result, my application is no longer available. However, I use the asynchronous option and the timeout and retry parameters. Here is my config below. How can I make sure that if the ElasticSearch service goes down, there is no performance impact in the application (High availability and resilience)?

 "targets": {
      "elastic": {
        "type": "ElasticSearch",
        "wrapperType": "AsyncWrapper",
        "uri": " ${configsetting:name=Elasticsearch.ConnectionUrl}",
        "connectionTimeout": "00:00:05",
        "maxRetries": "2",
        "throwExceptions": false,
        "retryDelayTime": "00:00:10",
        "requireAuth": false,
        "index": "${date:format=yyyy-MM-dd}-dotnet-${level}",
        "documentType": "",
        "layout": ...
        }
      }

Logs :

# OriginalException: 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: Une tentative de connexion a échoué car le parti connecté n’a pas répondu convenablement au-delà d’une certaine durée ou une connexion établie a échoué car l’hôte de connexion n’a pas répondu. (192.168.0.15:9200)

I guess the best solution is writing to a JSON-file (or console-output) using NLog EcsLayout (Or a own NLog JsonLayout that output in Elastic Common Schema), and then have Elastic-FileBeat upload to Elastic.