From: Fabian Röhl Date: Fri, 13 Oct 2017 12:54:00 +0000 (+0200) Subject: Add pdv unit to influxdbwriter if not empty + doc X-Git-Tag: v2.9.0~323^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=82794474e6e380381eb70d5260dee989f92aa314;p=icinga2 Add pdv unit to influxdbwriter if not empty + doc refs #5627 --- diff --git a/doc/14-features.md b/doc/14-features.md index fe5761ece..7357b1d6c 100644 --- a/doc/14-features.md +++ b/doc/14-features.md @@ -269,7 +269,7 @@ expects the InfluxDB daemon to listen at `127.0.0.1` on port `8086`. Measurement names and tags are fully configurable by the end user. The InfluxdbWriter object will automatically add a `metric` tag to each data point. This correlates to the -perfdata label. Fields (value, warn, crit, min, max) are created from data if available +perfdata label. Fields (value, warn, crit, min, max, unit) are created from data if available and the configuration allows it. If a value associated with a tag is not able to be resolved, it will be dropped and not sent to the target host. diff --git a/lib/perfdata/influxdbwriter.cpp b/lib/perfdata/influxdbwriter.cpp index aa35fec0e..9b9bd7410 100644 --- a/lib/perfdata/influxdbwriter.cpp +++ b/lib/perfdata/influxdbwriter.cpp @@ -264,6 +264,9 @@ void InfluxdbWriter::SendPerfdata(const Dictionary::Ptr& tmpl, const Checkable:: if (pdv->GetMax()) fields->Set("max", pdv->GetMax()); } + if (!pdv->GetUnit().IsEmpty()) { + fields->Set("unit", pdv->GetUnit()); + } SendMetric(tmpl, pdv->GetLabel(), fields, ts); }