mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-26 07:04:37 +02:00
Fix connection error handling in Elasticsearch and InfluxDB features
Previously this would just throw the entire exception stack trace which is not needed here. fixes #6394
This commit is contained in:
parent
d2a6b260bb
commit
9ea0650edc
@ -428,7 +428,19 @@ void ElasticsearchWriter::SendRequest(const String& body)
|
|||||||
|
|
||||||
url->SetPath(path);
|
url->SetPath(path);
|
||||||
|
|
||||||
Stream::Ptr stream = Connect();
|
Stream::Ptr stream;
|
||||||
|
|
||||||
|
try {
|
||||||
|
stream = Connect();
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
Log(LogWarning, "ElasticsearchWriter")
|
||||||
|
<< "Flush failed, cannot connect to Elasticsearch.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stream)
|
||||||
|
return;
|
||||||
|
|
||||||
HttpRequest req(stream);
|
HttpRequest req(stream);
|
||||||
|
|
||||||
/* Specify required headers by Elasticsearch. */
|
/* Specify required headers by Elasticsearch. */
|
||||||
|
@ -419,7 +419,15 @@ void InfluxdbWriter::Flush()
|
|||||||
String body = boost::algorithm::join(m_DataBuffer, "\n");
|
String body = boost::algorithm::join(m_DataBuffer, "\n");
|
||||||
m_DataBuffer.clear();
|
m_DataBuffer.clear();
|
||||||
|
|
||||||
Stream::Ptr stream = Connect();
|
Stream::Ptr stream;
|
||||||
|
|
||||||
|
try {
|
||||||
|
stream = Connect();
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
Log(LogWarning, "InfluxDbWriter")
|
||||||
|
<< "Flush failed, cannot connect to InfluxDB.";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!stream)
|
if (!stream)
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user