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

Content-type for Elasticsearch should be "application/x-ndjson" #6609

Closed
micoq opened this issue Sep 12, 2018 · 4 comments · Fixed by #7035
Closed

Content-type for Elasticsearch should be "application/x-ndjson" #6609

micoq opened this issue Sep 12, 2018 · 4 comments · Fixed by #7035
Assignees
Labels
area/elastic Events to Elasticsearch enhancement New feature or request
Milestone

Comments

@micoq
Copy link

micoq commented Sep 12, 2018

Currently the ElasticsearchWriter use application/json for the events sent to Elasticsearch.

However, Elasticsearch defines a special content type application/x-ndjson since the content are not strictly a single JSON object but multiple JSON objects separated by newlines (the "bulk" format):
https://www.elastic.co/guide/en/elasticsearch/reference/6.0/docs-bulk.html

application/json is deprecated in Elasticsearch (since the version 5.3) and some applications which accept the bulk format (Logstash with the codec es_bulk) can drop the data after the first line (the first JSON object).

@dnsmichi
Copy link
Contributor

It is not clear from Elastic whether this content-type should be the new standard, or if they ever remove application/json.

See my comment: #5795 (comment)
The deprecation issue: elastic/elasticsearch#25718
Rsyslog removed the change causing problems: rsyslog/rsyslog#1743

I'm waiting until Elastic decides where to head, until then it stays "as is". In terms of Logstash - that might break, but is not the target of this feature (first time I've heard of es_bulk).

@dnsmichi dnsmichi added needs feedback We'll only proceed once we hear from you again area/elastic Events to Elasticsearch TBD To be defined - We aren't certain about this yet labels Sep 12, 2018
@micoq
Copy link
Author

micoq commented Sep 12, 2018

I didn't tried to connect Icinga 2 directly to Elasticsearch yet, the initial idea was to use the input plugin logstash-input-http with the codec logstash-codec-es_bulk to collect checks results into a message bus (but the event REST API seems a better choice for this).

I didn't know the type application/ndjson was already defined.

Anyways, logstash-input-http can be configured to accept bulks with the content-type application/json:

http {
    ...
    additional_codecs => {"application/json" => "es_bulk"}
    ...
}

@dnsmichi dnsmichi removed the needs feedback We'll only proceed once we hear from you again label Sep 14, 2018
@lippserd
Copy link
Member

lippserd commented Feb 6, 2019

I think that we should use application/x-ndjson as header for the bulk API.

@lippserd lippserd added good first issue Good for newcomers and removed TBD To be defined - We aren't certain about this yet labels Feb 6, 2019
@lippserd lippserd added this to the 2.11.0 milestone Feb 6, 2019
@dnsmichi dnsmichi self-assigned this Mar 20, 2019
@dnsmichi dnsmichi added enhancement New feature or request and removed good first issue Good for newcomers labels Mar 20, 2019
dnsmichi pushed a commit that referenced this issue Mar 20, 2019
@dnsmichi
Copy link
Contributor

Elastic discusses the deprecation meanwhile, seems they cannot really drop it because of Kibana and apps. Anyhow, the change is just one line plus a comment, so it is done and also verified tested.

Screen Shot 2019-03-20 at 10 12 55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/elastic Events to Elasticsearch enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants