From 27a41804fc77444bea7591165271fa902c2f0645 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 20 Mar 2019 10:13:38 +0100 Subject: [PATCH] Elasticsearch: Change Content-Type header to 'application/x-ndjson' for bulk streams fixes #6609 --- doc/16-upgrading-icinga-2.md | 1 + lib/perfdata/elasticsearchwriter.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/16-upgrading-icinga-2.md b/doc/16-upgrading-icinga-2.md index cbe6cf142..aebbcf51c 100644 --- a/doc/16-upgrading-icinga-2.md +++ b/doc/16-upgrading-icinga-2.md @@ -27,6 +27,7 @@ This affects the following features: * [OpenTsdb](09-object-types.md#objecttype-opentsdbwriter) * [Perfdata](09-object-types.md#objecttype-perfdatawriter) (for PNP) + ### Package Dependencies #### Removed: YAJL diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index 976813aca..8b2aa8bda 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -456,7 +456,12 @@ void ElasticsearchWriter::SendRequest(const String& body) /* Specify required headers by Elasticsearch. */ req.AddHeader("Accept", "application/json"); - req.AddHeader("Content-Type", "application/json"); + + /* Use application/x-ndjson for bulk streams. While ES + * is able to handle application/json, the newline separator + * causes problems with Logstash (#6609). + */ + req.AddHeader("Content-Type", "application/x-ndjson"); /* Send authentication if configured. */ String username = GetUsername();