Skip to content

Commit

Permalink
Addressed additional comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kenrowland committed Nov 5, 2024
1 parent a3dd106 commit cd1fc60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion helm/examples/metrics/elasticsearch_metrics.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Defines a elastic sink for reporting metrics to an ElasticSearch instance
# Defines an elastic sink for reporting metrics to an ElasticSearch instance
# Settings:
# type - sink type (must be elastic for ElasticSearch support)
# name - name for the sink instance
Expand Down
31 changes: 19 additions & 12 deletions system/metrics/sinks/elastic/elasticSink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,19 @@ ElasticMetricSink::ElasticMetricSink(const char *name, const IPropertyTree *pSet
StringBuffer hostPort;

Owned<IPropertyTree> pHostConfigTree = pSettingsTree->getPropTree("host");

pHostConfigTree->getProp("@name", hostName);

if (!pHostConfigTree->getProp("@protocol", hostProtocol))
if (pHostConfigTree)
{
hostProtocol.append("https");
}
pHostConfigTree->getProp("@name", hostName);

if (!pHostConfigTree->getProp("@port", hostPort))
{
hostPort.append("9200");
if (!pHostConfigTree->getProp("@protocol", hostProtocol))
{
hostProtocol.append("https");
}

if (!pHostConfigTree->getProp("@port", hostPort))
{
hostPort.append("9200");
}
}

if (!hostName.isEmpty() && !hostPort.isEmpty() && !hostProtocol.isEmpty())
Expand All @@ -67,16 +69,21 @@ ElasticMetricSink::ElasticMetricSink(const char *name, const IPropertyTree *pSet
}
else
{
WARNLOG("ElasticMetricSink: Host configuration is invalid");
WARNLOG("ElasticMetricSink: Host configuration missing or invalid");
}

Owned<IPropertyTree> pIndexConfigTree = pSettingsTree->getPropTree("index");
pSettingsTree->getProp("@name", indexName);
if (pIndexConfigTree)
{
pSettingsTree->getProp("@name", indexName);
}

if (indexName.isEmpty())
{
WARNLOG("ElasticMetricSink: Index configuration is invalid");
WARNLOG("ElasticMetricSink: Index configuration missing or invalid");
}


// Both a host url and an index name are required
configurationValid = !elasticHostUrl.isEmpty() && !indexName.isEmpty();

Expand Down

0 comments on commit cd1fc60

Please sign in to comment.