Merge pull request #6219 from Icinga/feature/elasticsearch-6

Add support for Elasticsearch 6
This commit is contained in:
Michael Friedrich 2018-04-17 15:05:00 +02:00 committed by GitHub
commit e7374b48cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 10 deletions

View File

@ -403,7 +403,7 @@ The check results include parsed performance data metrics if enabled.
> **Note** > **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. 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: The following characters are escaped in perfdata labels:
Character | Escaped character Character | Escaped character
--------------|-------------------------- ------------|--------------------------
whitespace | _ whitespace | _
\ | _ \ | _
/ | _ / | _
:: | . :: | .
Note that perfdata labels may contain dots (`.`) allowing to Note that perfdata labels may contain dots (`.`) allowing to
add more subsequent levels inside the tree. add more subsequent levels inside the tree.

View File

@ -353,11 +353,10 @@ void ElasticsearchWriter::Enqueue(const String& type, const Dictionary::Ptr& fie
String eventType = m_EventPrefix + type; String eventType = m_EventPrefix + type;
fields->Set("type", eventType); 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. * We do it this way to avoid problems with a near full queue.
*/ */
String indexBody = "{\"index\": {} }\n";
String indexBody = R"({ "index" : { "_type" : ")" + eventType + "\" } }\n";
String fieldsBody = JsonEncode(fields); String fieldsBody = JsonEncode(fields);
Log(LogDebug, "ElasticsearchWriter") Log(LogDebug, "ElasticsearchWriter")
@ -419,6 +418,11 @@ void ElasticsearchWriter::SendRequest(const String& body)
*/ */
path.emplace_back(GetIndex() + "-" + Utility::FormatDateTime("%Y.%m.%d", Utility::GetTime())); 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. */ /* Use the bulk message format. */
path.emplace_back("_bulk"); path.emplace_back("_bulk");