From 313f25163b0394497b3a20929380c8f8f9233f59 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 3 Apr 2018 14:49:50 +0200 Subject: [PATCH] Elasticsearch/GELF: Add metric unit to performance data fields Seen this inside the InfluxDBWriter code, makes sense to store this in Elasticsearch too. --- lib/perfdata/elasticsearchwriter.cpp | 3 +++ lib/perfdata/gelfwriter.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index d27aec227..75f03b727 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -166,6 +166,9 @@ void ElasticsearchWriter::AddCheckResult(const Dictionary::Ptr& fields, const Ch fields->Set(perfdataPrefix + ".warn", pdv->GetWarn()); if (pdv->GetCrit()) fields->Set(perfdataPrefix + ".crit", pdv->GetCrit()); + + if (!pdv->GetUnit().IsEmpty()) + fields->Set(perfdataPrefix + ".unit", pdv->GetUnit()); } } } diff --git a/lib/perfdata/gelfwriter.cpp b/lib/perfdata/gelfwriter.cpp index ca9008127..48ed08294 100644 --- a/lib/perfdata/gelfwriter.cpp +++ b/lib/perfdata/gelfwriter.cpp @@ -269,6 +269,9 @@ void GelfWriter::CheckResultHandlerInternal(const Checkable::Ptr& checkable, con fields->Set("_" + escaped_key + "_warn", pdv->GetWarn()); if (pdv->GetCrit()) fields->Set("_" + escaped_key + "_crit", pdv->GetCrit()); + + if (!pdv->GetUnit().IsEmpty()) + fields->Set("_" + escaped_key + "_unit", pdv->GetUnit()); } } } -- 2.40.0