mirror of https://github.com/Icinga/icinga2.git
Merge pull request #6401 from Icinga/fix/elastic-influxdb-writer-connection-error-handling
Fix connection error handling in Elasticsearch and InfluxDB features
This commit is contained in:
commit
418d1ae343
|
@ -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…
Reference in New Issue