]> granicus.if.org Git - icinga2/commitdiff
Improve logging of ElasticsearchWriter
authorMichael Friedrich <michael.friedrich@icinga.com>
Tue, 19 Mar 2019 08:01:12 +0000 (09:01 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Tue, 19 Mar 2019 08:39:14 +0000 (09:39 +0100)
lib/perfdata/elasticsearchwriter.cpp
lib/perfdata/elasticsearchwriter.hpp

index f1a84a5af517c9c2ca34d140529c8a55478cf1d3..976813aca56e874a36ad98f0ac9f55c77746c943 100644 (file)
@@ -127,6 +127,8 @@ void ElasticsearchWriter::AddCheckResult(const Dictionary::Ptr& fields, const Ch
 
        Array::Ptr perfdata = cr->GetPerformanceData();
 
+       CheckCommand::Ptr checkCommand = checkable->GetCheckCommand();
+
        if (perfdata) {
                ObjectLock olock(perfdata);
                for (const Value& val : perfdata) {
@@ -139,8 +141,9 @@ void ElasticsearchWriter::AddCheckResult(const Dictionary::Ptr& fields, const Ch
                                        pdv = PerfdataValue::Parse(val);
                                } catch (const std::exception&) {
                                        Log(LogWarning, "ElasticsearchWriter")
-                                               << "Ignoring invalid perfdata value: '" << val << "' for object '"
-                                               << checkable->GetName() << "'.";
+                                               << "Ignoring invalid perfdata for checkable '"
+                                               << checkable->GetName() << "' and command '"
+                                               << checkCommand->GetName() << "' with value: " << val;
                                        continue;
                                }
                        }
@@ -224,7 +227,7 @@ void ElasticsearchWriter::InternalCheckResultHandler(const Checkable::Ptr& check
                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)
@@ -274,7 +277,7 @@ void ElasticsearchWriter::StateChangeHandlerInternal(const Checkable::Ptr& check
                ts = cr->GetExecutionEnd();
        }
 
-       Enqueue("statechange", fields, ts);
+       Enqueue(checkable, "statechange", fields, ts);
 }
 
 void ElasticsearchWriter::NotificationSentToAllUsersHandler(const Notification::Ptr& notification,
@@ -343,10 +346,11 @@ void ElasticsearchWriter::NotificationSentToAllUsersHandlerInternal(const Notifi
                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. */
        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);
 
        Log(LogDebug, "ElasticsearchWriter")
-               << "Add to fields to message list: '" << fieldsBody << "'.";
+               << "Checkable '" << checkable->GetName() << "' adds to metric list: '" << fieldsBody << "'.";
 
        m_DataBuffer.emplace_back(indexBody + fieldsBody);
 
index 2f8e59eb0f96c9ae8f8223edf6cba3d2c0974427..cf60044cd9a2655bd1acc0a3ba51d7cd2051100e 100644 (file)
@@ -47,7 +47,8 @@ private:
                const Checkable::Ptr& checkable, const std::set<User::Ptr>& users, NotificationType type,
                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();
        void AssertOnWorkQueue();