Skip to content

Commit cb7fa99

Browse files
BrandonArpvjkoskela
authored andcommitted
add a monitoring uri config (#96)
* add a monitoring uri config * use host and port instead of URI
1 parent 4402a90 commit cb7fa99

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

src/main/java/com/arpnetworking/clusteraggregator/GuiceModule.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777

7878
import java.io.File;
7979
import java.io.IOException;
80+
import java.net.URI;
81+
import java.net.URISyntaxException;
8082
import java.util.Collections;
8183
import java.util.Locale;
8284
import java.util.Map;
@@ -141,8 +143,12 @@ private Config provideAkkaConfig() {
141143
@Provides
142144
@Singleton
143145
@SuppressFBWarnings("UPM_UNCALLED_PRIVATE_METHOD") // Invoked reflectively by Guice
144-
private MetricsFactory provideMetricsFactory() {
146+
private MetricsFactory provideMetricsFactory() throws URISyntaxException {
145147
final Sink sink = new ApacheHttpSink.Builder()
148+
.setUri(new URI(String.format(
149+
"http://%s:%d/metrics/v2/application",
150+
_configuration.getMonitoringHost(),
151+
_configuration.getMonitoringPort())))
146152
.build();
147153

148154
return new TsdMetricsFactory.Builder()

src/main/java/com/arpnetworking/clusteraggregator/configuration/ClusterAggregatorConfiguration.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ public String getMonitoringService() {
5353
return _monitoringService;
5454
}
5555

56+
public String getMonitoringHost() {
57+
return _monitoringHost;
58+
}
59+
60+
public int getMonitoringPort() {
61+
return _monitoringPort;
62+
}
63+
5664
public int getHttpPort() {
5765
return _httpPort;
5866
}
@@ -164,6 +172,8 @@ public String toString() {
164172
private ClusterAggregatorConfiguration(final Builder builder) {
165173
_monitoringCluster = builder._monitoringCluster;
166174
_monitoringService = builder._monitoringService;
175+
_monitoringHost = builder._monitoringHost;
176+
_monitoringPort = builder._monitoringPort;
167177
_httpHost = builder._httpHost;
168178
_httpPort = builder._httpPort;
169179
_httpHealthCheckPath = builder._httpHealthCheckPath;
@@ -188,6 +198,8 @@ private ClusterAggregatorConfiguration(final Builder builder) {
188198

189199
private final String _monitoringCluster;
190200
private final String _monitoringService;
201+
private final String _monitoringHost;
202+
private final int _monitoringPort;
191203
private final File _logDirectory;
192204
private final String _httpHost;
193205
private final int _httpPort;
@@ -245,6 +257,30 @@ public Builder setMonitoringService(final String value) {
245257
return this;
246258
}
247259

260+
/**
261+
* The monitoring endpoint host (Where to post data). Optional. Cannot be null or empty. Default
262+
* is 'localhost'.
263+
*
264+
* @param value The monitoring endpoint uri.
265+
* @return This instance of <code>Builder</code>.
266+
*/
267+
public Builder setMonitoringHost(final String value) {
268+
_monitoringHost = value;
269+
return this;
270+
}
271+
272+
/**
273+
* The monitoring endpoint port. Optional. Cannot be null, must be between 1 and
274+
* 65535 (inclusive). Defaults to 7090.
275+
*
276+
* @param value The port to listen on.
277+
* @return This instance of <code>Builder</code>.
278+
*/
279+
public Builder setMonitoringPort(final Integer value) {
280+
_monitoringPort = value;
281+
return this;
282+
}
283+
248284
/**
249285
* The http host address to bind to. Cannot be null or empty.
250286
*
@@ -489,6 +525,12 @@ public Builder setCalculateClusterAggregations(final Boolean value) {
489525
private String _monitoringService = "cluster_aggregator";
490526
@NotNull
491527
@NotEmpty
528+
private String _monitoringHost = "localhost";
529+
@NotNull
530+
@Range(min = 1, max = 65535)
531+
private Integer _monitoringPort = 7090;
532+
@NotNull
533+
@NotEmpty
492534
private String _httpHost = "0.0.0.0";
493535
@NotNull
494536
@Range(min = 1, max = 65535)

0 commit comments

Comments
 (0)