mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
Improve logging of ElasticsearchWriter
This commit is contained in:
parent
aa93c382e1
commit
783a4c832c
@ -127,6 +127,8 @@ void ElasticsearchWriter::AddCheckResult(const Dictionary::Ptr& fields, const Ch
|
|||||||
|
|
||||||
Array::Ptr perfdata = cr->GetPerformanceData();
|
Array::Ptr perfdata = cr->GetPerformanceData();
|
||||||
|
|
||||||
|
CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
|
||||||
|
|
||||||
if (perfdata) {
|
if (perfdata) {
|
||||||
ObjectLock olock(perfdata);
|
ObjectLock olock(perfdata);
|
||||||
for (const Value& val : perfdata) {
|
for (const Value& val : perfdata) {
|
||||||
@ -139,8 +141,9 @@ void ElasticsearchWriter::AddCheckResult(const Dictionary::Ptr& fields, const Ch
|
|||||||
pdv = PerfdataValue::Parse(val);
|
pdv = PerfdataValue::Parse(val);
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception&) {
|
||||||
Log(LogWarning, "ElasticsearchWriter")
|
Log(LogWarning, "ElasticsearchWriter")
|
||||||
<< "Ignoring invalid perfdata value: '" << val << "' for object '"
|
<< "Ignoring invalid perfdata for checkable '"
|
||||||
<< checkable->GetName() << "'.";
|
<< checkable->GetName() << "' and command '"
|
||||||
|
<< checkCommand->GetName() << "' with value: " << val;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,7 +227,7 @@ void ElasticsearchWriter::InternalCheckResultHandler(const Checkable::Ptr& check
|
|||||||
ts = cr->GetExecutionEnd();
|
ts = cr->GetExecutionEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
Enqueue("checkresult", fields, ts);
|
Enqueue(checkable, "checkresult", fields, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElasticsearchWriter::StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type)
|
void ElasticsearchWriter::StateChangeHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type)
|
||||||
@ -274,7 +277,7 @@ void ElasticsearchWriter::StateChangeHandlerInternal(const Checkable::Ptr& check
|
|||||||
ts = cr->GetExecutionEnd();
|
ts = cr->GetExecutionEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
Enqueue("statechange", fields, ts);
|
Enqueue(checkable, "statechange", fields, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElasticsearchWriter::NotificationSentToAllUsersHandler(const Notification::Ptr& notification,
|
void ElasticsearchWriter::NotificationSentToAllUsersHandler(const Notification::Ptr& notification,
|
||||||
@ -343,10 +346,11 @@ void ElasticsearchWriter::NotificationSentToAllUsersHandlerInternal(const Notifi
|
|||||||
ts = cr->GetExecutionEnd();
|
ts = cr->GetExecutionEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
Enqueue("notification", fields, ts);
|
Enqueue(checkable, "notification", fields, ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ElasticsearchWriter::Enqueue(const String& type, const Dictionary::Ptr& fields, double ts)
|
void ElasticsearchWriter::Enqueue(const Checkable::Ptr& checkable, const String& type,
|
||||||
|
const Dictionary::Ptr& fields, double ts)
|
||||||
{
|
{
|
||||||
/* Atomically buffer the data point. */
|
/* Atomically buffer the data point. */
|
||||||
boost::mutex::scoped_lock lock(m_DataBufferMutex);
|
boost::mutex::scoped_lock lock(m_DataBufferMutex);
|
||||||
@ -365,7 +369,7 @@ void ElasticsearchWriter::Enqueue(const String& type, const Dictionary::Ptr& fie
|
|||||||
String fieldsBody = JsonEncode(fields);
|
String fieldsBody = JsonEncode(fields);
|
||||||
|
|
||||||
Log(LogDebug, "ElasticsearchWriter")
|
Log(LogDebug, "ElasticsearchWriter")
|
||||||
<< "Add to fields to message list: '" << fieldsBody << "'.";
|
<< "Checkable '" << checkable->GetName() << "' adds to metric list: '" << fieldsBody << "'.";
|
||||||
|
|
||||||
m_DataBuffer.emplace_back(indexBody + fieldsBody);
|
m_DataBuffer.emplace_back(indexBody + fieldsBody);
|
||||||
|
|
||||||
|
@ -47,7 +47,8 @@ private:
|
|||||||
const Checkable::Ptr& checkable, const std::set<User::Ptr>& users, NotificationType type,
|
const Checkable::Ptr& checkable, const std::set<User::Ptr>& users, NotificationType type,
|
||||||
const CheckResult::Ptr& cr, const String& author, const String& text);
|
const CheckResult::Ptr& cr, const String& author, const String& text);
|
||||||
|
|
||||||
void Enqueue(const String& type, const Dictionary::Ptr& fields, double ts);
|
void Enqueue(const Checkable::Ptr& checkable, const String& type,
|
||||||
|
const Dictionary::Ptr& fields, double ts);
|
||||||
|
|
||||||
Stream::Ptr Connect();
|
Stream::Ptr Connect();
|
||||||
void AssertOnWorkQueue();
|
void AssertOnWorkQueue();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user