Skip to content

Commit

Permalink
Address additional review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kenrowland committed Jan 8, 2025
1 parent 5808b32 commit b646bf1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
3 changes: 3 additions & 0 deletions helm/examples/metrics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,9 @@ The host settings define the server hosting ElasticSearch to which metrics are r
* port - The port number of the ElasticSearch server. (default: 9200)
* certificateFilePath - Path to the file containing the certificate used to connect to the ElasticSearch server.
(optional)
* connectTimeout - The time in seconds to wait for a connection to be established to the (default: 5)
* readTimeout - The time in seconds to wait for a response from the server for a read operation. (default: 5)
* writeTimeout - The time in seconds to wait for a response from the server for a write operation. (default: 5)

**Authentication**

Expand Down
20 changes: 14 additions & 6 deletions system/metrics/sinks/elastic/elasticSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ElasticMetricSink::ElasticMetricSink(const char *name, const IPropertyTree *pSet
}
else
{
PROGLOG("ElasticMetricSink: Unable to complete initialization, sink not collecting");
WARNLOG("ElasticMetricSink: Unable to complete initialization, sink not collecting");
}
}

Expand Down Expand Up @@ -132,6 +132,12 @@ bool ElasticMetricSink::getHostConfig(const IPropertyTree *pSettingsTree)
decrypt(password, encryptedPassword.str()); //MD5 encrypted in config
}
}

// Read optional timeout values
connectTimeout = pHostConfigTree->getPropInt("@connectionTimeout", connectTimeout);
readTimeout = pHostConfigTree->getPropInt("@readTimeout", readTimeout);
writeTimeout = pHostConfigTree->getPropInt("@writeTimeout", writeTimeout);

return true;
}

Expand Down Expand Up @@ -180,7 +186,8 @@ bool ElasticMetricSink::getDynamicMappingSuffixesFromIndex(const IPropertyTree *

if (res == nullptr)
{
WARNLOG("ElasticMetricSink: Unable to connect to ElasticSearch host %s", elasticHostUrl.str());
httplib::Error err = res.error();
WARNLOG("ElasticMetricSink: Unable to connect to ElasticSearch host '%s', httplib Error = %d", elasticHostUrl.str(), err);
return false;
}

Expand Down Expand Up @@ -299,9 +306,9 @@ void ElasticMetricSink::intializeElasticClient()
if (!certificateFilePath.isEmpty())
pClient->set_ca_cert_path(certificateFilePath.str());

pClient->set_connection_timeout(5);
pClient->set_read_timeout(5);
pClient->set_write_timeout(5);
pClient->set_connection_timeout(connectTimeout);
pClient->set_read_timeout(readTimeout);
pClient->set_write_timeout(writeTimeout);
}


Expand Down Expand Up @@ -331,7 +338,8 @@ bool ElasticMetricSink::validateIndex()

if (res == nullptr)
{
WARNLOG("ElasticMetricSink: Unable to connect to ElasticSearch host %s", elasticHostUrl.str());
httplib::Error err = res.error();
WARNLOG("ElasticMetricSink: Unable to connect to ElasticSearch host '%s, httplib Error = %d", elasticHostUrl.str(), err);
return false;
}

Expand Down
3 changes: 3 additions & 0 deletions system/metrics/sinks/elastic/elasticSink.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ class ELASTICSINK_API ElasticMetricSink : public hpccMetrics::PeriodicMetricSink
StringBuffer countMetricSuffix;
StringBuffer gaugeMetricSuffix;
StringBuffer histogramMetricSuffix;
int connectTimeout = 5;
int readTimeout = 5;
int writeTimeout = 5;
bool configurationValid = false;
std::shared_ptr<httplib::Client> pClient;
httplib::Headers elasticHeaders;
Expand Down

0 comments on commit b646bf1

Please sign in to comment.