]> granicus.if.org Git - icinga2/commitdiff
Elasticsearch/GELF: Add metric unit to performance data fields 6194/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Tue, 3 Apr 2018 12:49:50 +0000 (14:49 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Tue, 3 Apr 2018 12:49:50 +0000 (14:49 +0200)
Seen this inside the InfluxDBWriter code, makes sense to store
this in Elasticsearch too.

lib/perfdata/elasticsearchwriter.cpp
lib/perfdata/gelfwriter.cpp

index d27aec22783a663e322fd7501c635eab5c2ed706..75f03b727da53ce68dafb67867e33d782ffdcbf9 100644 (file)
@@ -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());
                }
        }
 }
index ca900812728b2211ab7c58088e310fb4c7da71bc..48ed08294be3b130946634ba069150f1cb39720f 100644 (file)
@@ -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());
                        }
                }
        }