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:
Michael Friedrich 2018-06-21 15:53:33 +02:00 committed by GitHub
commit 418d1ae343
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 2 deletions

View File

@ -428,7 +428,19 @@ void ElasticsearchWriter::SendRequest(const String& body)
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);
/* Specify required headers by Elasticsearch. */

View File

@ -419,7 +419,15 @@ void InfluxdbWriter::Flush()
String body = boost::algorithm::join(m_DataBuffer, "\n");
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)
return;