Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for EnableApiVersioningHeader option for servers v8+ #156

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

Rassi
Copy link
Contributor

@Rassi Rassi commented Apr 22, 2022

We have upgraded Elastic server to version 8.1.3 and experienced errors. After reading https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/connecting-to-elasticsearch-v8.html#enabling-compatibility-mode and elastic/elasticsearch-net#6154 we tried setting the ELASTIC_CLIENT_APIVERSIONING environment variable which fixed it.

One of our applications, though, connects to two different Elastic servers, one for logging and one for a search index. The search index server is on version 7.10 which does not yet support ApiVersioningHeader, and we cannot upgrade it yet. Thus we need NLog target to run with EnableApiVersioningHeader and the other client without.

This PR adds support for enabling ApiVersioningHeader just for the NLog target from config.

A limitation is, that it will not work when enabling it for servers running <7.13 (as per elastic/elasticsearch-net#6154 (comment)) but I think that could be adequately explained in documentation.

Checklist

@Rassi
Copy link
Contributor Author

Rassi commented Apr 25, 2022

It was the following low level error:

Invalid NEST response built from a successful (200) low level call on POST: /_bulk
# Invalid Bulk items:
  operation[0]: index returned 201 _index: x-2022.04.21 _type:  _id: vUmiS4ABsXhEMlfGFdaJ _version: 1 error: 
# Audit trail of this API call:
 - [1] PingSuccess: Node: https://x/ Took: 00:00:00.2103319
 - [2] HealthyResponse: Node: https://x/ Took: 00:00:00.3831254
# Request:
<Request stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>
# Response:
<Response stream not captured or already read to completion by serializer. Set DisableDirectStreaming() on ConnectionSettings to force it to be set on the response.>

@snakefoot
Copy link
Collaborator

@markmcdowell Think all 3 pull-requests #156 + #159 + #160 should be merged, and then release NLog.Targets.ElasticSearch ver. 7.8

@markmcdowell markmcdowell merged commit 1c914d7 into markmcdowell:master Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants