mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Improve logging of InfluxdbWriter
This commit is contained in:
parent
82dcb3965b
commit
aa93c382e1
@ -246,7 +246,10 @@ void InfluxdbWriter::CheckResultHandlerWQ(const Checkable::Ptr& checkable, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
|
||||||
|
|
||||||
Array::Ptr perfdata = cr->GetPerformanceData();
|
Array::Ptr perfdata = cr->GetPerformanceData();
|
||||||
|
|
||||||
if (perfdata) {
|
if (perfdata) {
|
||||||
ObjectLock olock(perfdata);
|
ObjectLock olock(perfdata);
|
||||||
for (const Value& val : perfdata) {
|
for (const Value& val : perfdata) {
|
||||||
@ -259,7 +262,9 @@ void InfluxdbWriter::CheckResultHandlerWQ(const Checkable::Ptr& checkable, const
|
|||||||
pdv = PerfdataValue::Parse(val);
|
pdv = PerfdataValue::Parse(val);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogWarning, "InfluxdbWriter")
|
Log(LogWarning, "InfluxdbWriter")
|
||||||
<< "Ignoring invalid perfdata value: " << val;
|
<< "Ignoring invalid perfdata for checkable '"
|
||||||
|
<< checkable->GetName() << "' and command '"
|
||||||
|
<< checkCommand->GetName() << "' with value: " << val;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -281,7 +286,7 @@ void InfluxdbWriter::CheckResultHandlerWQ(const Checkable::Ptr& checkable, const
|
|||||||
fields->Set("unit", pdv->GetUnit());
|
fields->Set("unit", pdv->GetUnit());
|
||||||
}
|
}
|
||||||
|
|
||||||
SendMetric(tmpl, pdv->GetLabel(), fields, ts);
|
SendMetric(checkable, tmpl, pdv->GetLabel(), fields, ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +311,7 @@ void InfluxdbWriter::CheckResultHandlerWQ(const Checkable::Ptr& checkable, const
|
|||||||
fields->Set("latency", cr->CalculateLatency());
|
fields->Set("latency", cr->CalculateLatency());
|
||||||
fields->Set("execution_time", cr->CalculateExecutionTime());
|
fields->Set("execution_time", cr->CalculateExecutionTime());
|
||||||
|
|
||||||
SendMetric(tmpl, Empty, fields, ts);
|
SendMetric(checkable, tmpl, Empty, fields, ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +354,8 @@ String InfluxdbWriter::EscapeValue(const Value& value)
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfluxdbWriter::SendMetric(const Dictionary::Ptr& tmpl, const String& label, const Dictionary::Ptr& fields, double ts)
|
void InfluxdbWriter::SendMetric(const Checkable::Ptr& checkable, const Dictionary::Ptr& tmpl,
|
||||||
|
const String& label, const Dictionary::Ptr& fields, double ts)
|
||||||
{
|
{
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << EscapeKeyOrTagValue(tmpl->Get("measurement"));
|
msgbuf << EscapeKeyOrTagValue(tmpl->Get("measurement"));
|
||||||
@ -387,10 +393,8 @@ void InfluxdbWriter::SendMetric(const Dictionary::Ptr& tmpl, const String& label
|
|||||||
|
|
||||||
msgbuf << " " << static_cast<unsigned long>(ts);
|
msgbuf << " " << static_cast<unsigned long>(ts);
|
||||||
|
|
||||||
#ifdef I2_DEBUG
|
|
||||||
Log(LogDebug, "InfluxdbWriter")
|
Log(LogDebug, "InfluxdbWriter")
|
||||||
<< "Add to metric list: '" << msgbuf.str() << "'.";
|
<< "Checkable '" << checkable->GetName() << "' adds to metric list:'" << msgbuf.str() << "'.";
|
||||||
#endif /* I2_DEBUG */
|
|
||||||
|
|
||||||
// Buffer the data point
|
// Buffer the data point
|
||||||
m_DataBuffer.emplace_back(msgbuf.str());
|
m_DataBuffer.emplace_back(msgbuf.str());
|
||||||
|
@ -42,7 +42,8 @@ private:
|
|||||||
|
|
||||||
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
void CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
||||||
void CheckResultHandlerWQ(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
void CheckResultHandlerWQ(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr);
|
||||||
void SendMetric(const Dictionary::Ptr& tmpl, const String& label, const Dictionary::Ptr& fields, double ts);
|
void SendMetric(const Checkable::Ptr& checkable, const Dictionary::Ptr& tmpl,
|
||||||
|
const String& label, const Dictionary::Ptr& fields, double ts);
|
||||||
void FlushTimeout();
|
void FlushTimeout();
|
||||||
void FlushTimeoutWQ();
|
void FlushTimeoutWQ();
|
||||||
void Flush();
|
void Flush();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user