|
@@ -23,6 +23,7 @@ import io.prometheus.client.CollectorRegistry;
|
|
import io.prometheus.client.exporter.MetricsServlet;
|
|
import io.prometheus.client.exporter.MetricsServlet;
|
|
import io.prometheus.client.hotspot.DefaultExports;
|
|
import io.prometheus.client.hotspot.DefaultExports;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
|
+import java.net.InetSocketAddress;
|
|
import java.util.Enumeration;
|
|
import java.util.Enumeration;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.Properties;
|
|
import java.util.Properties;
|
|
@@ -63,6 +64,7 @@ public class PrometheusMetricsProvider implements MetricsProvider {
|
|
* </p>
|
|
* </p>
|
|
*/
|
|
*/
|
|
private final CollectorRegistry collectorRegistry = CollectorRegistry.defaultRegistry;
|
|
private final CollectorRegistry collectorRegistry = CollectorRegistry.defaultRegistry;
|
|
|
|
+ private String host = "0.0.0.0";
|
|
private int port = 7000;
|
|
private int port = 7000;
|
|
private boolean exportJvmInfo = true;
|
|
private boolean exportJvmInfo = true;
|
|
private Server server;
|
|
private Server server;
|
|
@@ -72,6 +74,7 @@ public class PrometheusMetricsProvider implements MetricsProvider {
|
|
@Override
|
|
@Override
|
|
public void configure(Properties configuration) throws MetricsProviderLifeCycleException {
|
|
public void configure(Properties configuration) throws MetricsProviderLifeCycleException {
|
|
LOG.info("Initializing metrics, configuration: {}", configuration);
|
|
LOG.info("Initializing metrics, configuration: {}", configuration);
|
|
|
|
+ this.host = configuration.getProperty("httpHost", "0.0.0.0");
|
|
this.port = Integer.parseInt(configuration.getProperty("httpPort", "7000"));
|
|
this.port = Integer.parseInt(configuration.getProperty("httpPort", "7000"));
|
|
this.exportJvmInfo = Boolean.parseBoolean(configuration.getProperty("exportJvmInfo", "true"));
|
|
this.exportJvmInfo = Boolean.parseBoolean(configuration.getProperty("exportJvmInfo", "true"));
|
|
}
|
|
}
|
|
@@ -79,11 +82,12 @@ public class PrometheusMetricsProvider implements MetricsProvider {
|
|
@Override
|
|
@Override
|
|
public void start() throws MetricsProviderLifeCycleException {
|
|
public void start() throws MetricsProviderLifeCycleException {
|
|
try {
|
|
try {
|
|
- LOG.info("Starting /metrics HTTP endpoint at port {} exportJvmInfo: {}", port, exportJvmInfo);
|
|
|
|
|
|
+ LOG.info("Starting /metrics HTTP endpoint at host: {}, port: {}, exportJvmInfo: {}",
|
|
|
|
+ host, port, exportJvmInfo);
|
|
if (exportJvmInfo) {
|
|
if (exportJvmInfo) {
|
|
DefaultExports.initialize();
|
|
DefaultExports.initialize();
|
|
}
|
|
}
|
|
- server = new Server(port);
|
|
|
|
|
|
+ server = new Server(new InetSocketAddress(host, port));
|
|
ServletContextHandler context = new ServletContextHandler();
|
|
ServletContextHandler context = new ServletContextHandler();
|
|
context.setContextPath("/");
|
|
context.setContextPath("/");
|
|
server.setHandler(context);
|
|
server.setHandler(context);
|