Influx DB: don't unneccessarily truncate timestamps to whole seconds

Instead send timestamps with the highest possible precision (ns).
Useful for check intervals <1s.
This commit is contained in:
Alexander A. Klimov 2022-11-28 12:27:01 +01:00
parent f855cfa155
commit eaa3cd83ad
1 changed files with 3 additions and 2 deletions

View File

@ -37,6 +37,7 @@
#include <boost/math/special_functions/fpclassify.hpp>
#include <boost/regex.hpp>
#include <boost/scoped_array.hpp>
#include <iomanip>
#include <memory>
#include <string>
#include <utility>
@ -398,7 +399,7 @@ void InfluxdbCommonWriter::SendMetric(const Checkable::Ptr& checkable, const Dic
}
}
msgbuf << " " << static_cast<unsigned long>(ts);
msgbuf << " " << std::fixed << std::setprecision(0) << ts * 1.0e9;
Log(LogDebug, GetReflectionType()->GetName())
<< "Checkable '" << checkable->GetName() << "' adds to metric list:'" << msgbuf.str() << "'.";
@ -553,7 +554,7 @@ Url::Ptr InfluxdbCommonWriter::AssembleBaseUrl()
url->SetScheme(GetSslEnable() ? "https" : "http");
url->SetHost(GetHost());
url->SetPort(GetPort());
url->AddQueryElement("precision", "s");
url->AddQueryElement("precision", "ns");
return url;
}