markmcdowell / NLog.Targets.ElasticSearch

NLog target for Elasticsearch
MIT License
176 stars 89 forks source link

Does NLog.Targets.ElasticSearch support logging to Elasticsearch 8? #176

Open mindisk opened 1 year ago

mindisk commented 1 year ago

I have updated NLog and NLog.Targets.ElasticSearch to latest versions and it worked against Elasticsearch 7. I have upgraded Elasticsearch to version 8. After that, I was unable to write logs to Elasticsearch.

After looking at NLog.Targets.ElasticSearch repository, I noticed that Elasticsearch 8 is not mentioned anywhere and that the latest package targets Elasticserach 7 and not 8.

Is it true that NLog.Targets.ElasticSearch does not support Elasticsearch 8 at the moment? If it is true, when I could expect support for Elasticsearch 8 to be available?

boskjoett commented 1 year ago

Adding documentType="" to target xsi:type="ElasticSearch" solved the issue.

<target xsi:type="ElasticSearch" index="${elasticSearchIndex}" uri="${elasticSearchUri}" username="${elasticSearchUsername}" password="${elasticSearchPassword}" documentType="">

It now works with ES 8.

The Versions table on the project front page makes you wonder if ES 8 is supported. I think you should highlight that this project supports ES 8, and mention the empty documentType requirement.

johnjaylward commented 3 months ago

Looks like data streams are not supported though:

2024-07-30 15:59:27.6445 Error ElasticSearch: Bulk item failed: index:my-stream result: type: error:Type: illegal_argument_exception Reason: "only write ops with an op_type of create are allowed in data streams" CausedBy: "Type: index_not_found_exception Reason: "no such index [my-stream]""

It's true that the my-stream index does not exist since it's actually a data stream

snakefoot commented 3 months ago

@johnjaylward The Wiki mentions that you can assign opCodeCreate="true" to enable data-streams. See also #132

johnjaylward commented 3 months ago

will settings opCodeCreate="true" still work for a regular index as well, or only data streams?

snakefoot commented 3 months ago

No idea. Maybe look in the ElasticSearch-manual or ask ElasticSearch-support or use StackOverflow.com or Google how opCode is working.