diff --git a/doc/14-features.md b/doc/14-features.md index 2ee09a06a..5e65cff00 100644 --- a/doc/14-features.md +++ b/doc/14-features.md @@ -403,7 +403,7 @@ The check results include parsed performance data metrics if enabled. > **Note** > -> Elasticsearch 5.x is required. This feature has been successfully tested with Elasticsearch 5.6.4. +> Elasticsearch 5.x or 6.x are required. This feature has been successfully tested with Elasticsearch 5.6.7 and 6.2.3. Enable the feature and restart Icinga 2. @@ -433,12 +433,12 @@ Metric values are stored like this: The following characters are escaped in perfdata labels: - Character | Escaped character - --------------|-------------------------- - whitespace | _ - \ | _ - / | _ - :: | . + Character | Escaped character + ------------|-------------------------- + whitespace | _ + \ | _ + / | _ + :: | . Note that perfdata labels may contain dots (`.`) allowing to add more subsequent levels inside the tree. diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index 87f299712..2e8ffa515 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -353,11 +353,10 @@ void ElasticsearchWriter::Enqueue(const String& type, const Dictionary::Ptr& fie String eventType = m_EventPrefix + type; fields->Set("type", eventType); - /* Every payload needs a line describing the index above. + /* Every payload needs a line describing the index. * We do it this way to avoid problems with a near full queue. */ - - String indexBody = R"({ "index" : { "_type" : ")" + eventType + "\" } }\n"; + String indexBody = "{\"index\": {} }\n"; String fieldsBody = JsonEncode(fields); Log(LogDebug, "ElasticsearchWriter") @@ -419,6 +418,11 @@ void ElasticsearchWriter::SendRequest(const String& body) */ path.emplace_back(GetIndex() + "-" + Utility::FormatDateTime("%Y.%m.%d", Utility::GetTime())); + /* ES 6 removes multiple _type mappings: https://www.elastic.co/guide/en/elasticsearch/reference/6.x/removal-of-types.html + * Best practice is to statically define 'doc', as ES 5.X does not allow types starting with '_'. + */ + path.emplace_back("doc"); + /* Use the bulk message format. */ path.emplace_back("_bulk");