Action/metadata line [1] contains an unknown parameter [_type]
timbze opened this issue · 3 comments
I'm trying to use this package to send my logs to Elasticsearch, but am getting the error below, and no logs are being sent. I am not sure if I need to configure something differently or if there's an incompatibility in these latest versions...
I'm using:
.NET 7.0 preview 6
NLog 5.1.0
NLog.Targets.ElasticSearch 7.7.0
Elasticsearch 8.3.2
My nlog.config
relevant parts:
<extensions>
<add assembly="NLog.Web.AspNetCore"/>
<add assembly="NLog.Targets.ElasticSearch"/>
</extensions>
<target name="elastic" xsi:type="BufferingWrapper" flushTimeout="5000">
<target xsi:type="ElasticSearch" uri="https://localhost:9200/" requireAuth="true" username="elastic" password="myPassword"
includeAllProperties="true" disableCertificateValidation="true" />
</target>
<logger name="*" minlevel="Trace" writeTo="elastic" />
NLog error:
2022-07-21 10:53:12.4831 Error ElasticSearch: Failed to send log messages. Status=400 Uri=https://localhost:9200/_bulk DebugInformation=Invalid NEST response built from a unsuccessful (400) low level call on POST: /_bulk
# Invalid Bulk items:
# Audit trail of this API call:
- [1] PingSuccess: Node: https://localhost:9200/ Took: 00:00:00.4700960
- [2] BadResponse: Node: https://localhost:9200/ Took: 00:00:00.2240682
# OriginalException: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: POST /_bulk. ServerError: Type: illegal_argument_exception Reason: "Action/metadata line [1] contains an unknown parameter [_type]"
# 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.>
Exception: Elasticsearch.Net.ElasticsearchClientException: Request failed to execute. Call: Status code 400 from: POST /_bulk. ServerError: Type: illegal_argument_exception Reason: "Action/metadata line [1] contains an unknown parameter [_type]"
As is usually the case, I spend hours trying to fix something, but the moment I create an issue then I see the solution in the wiki that I've been looking through this whole time 🤦🏽♂️
When connecting to Elastic-Server 8.0 make sure to use documentType="" to avoid unknown parameter error.
Now I get another error for each log, will see if I can still figure that out
Error ElasticSearch: Bulk item failed: index:logstash-2022.07.21 result:created type: error:
Now I get another error for each log, will see if I can still figure that out
I don't know yet what that issue is, but it's different from OP so will close this issue
For everyone stumbling over the same chain of issues after a ElasticSearch v8 upgrade:
You can fix ElasticSearch: Bulk item failed: index:logstash-2022.07.21 result:created type: error:
by enabling the client compatibility mode. To enable the compatibility mode, set the ELASTIC_CLIENT_APIVERSIONING
environment variable to true
. (https://www.elastic.co/guide/en/elasticsearch/client/net-api/7.17/connecting-to-elasticsearch-v8.html#enabling-compatibility-mode)