use of org.apache.bookkeeper.stats.prometheus.PrometheusMetricsProvider in project herddb by diennea.
the class ServerMain method start.
public void start() throws Exception {
pidFileLocker.lock();
PrometheusMetricsProvider statsProvider = new PrometheusMetricsProvider();
PropertiesConfiguration statsProviderConfig = new PropertiesConfiguration();
statsProviderConfig.setProperty(PrometheusMetricsProvider.PROMETHEUS_STATS_HTTP_ENABLE, false);
configuration.forEach((key, value) -> {
statsProviderConfig.setProperty(key + "", value);
});
statsProvider.start(statsProviderConfig);
ServerConfiguration config = new ServerConfiguration(this.configuration);
StatsLogger statsLogger = statsProvider.getStatsLogger("");
server = new Server(config, statsLogger);
server.start();
boolean httpEnabled = config.getBoolean("http.enable", true);
if (httpEnabled) {
String httphost = config.getString("http.host", server.getNetworkServer().getHost());
String httpadvertisedhost = config.getString("http.advertised.host", server.getServerHostData().getHost());
int httpport = config.getInt("http.port", 9845);
int httpadvertisedport = config.getInt("http.advertised.port", httpport);
httpserver = new org.eclipse.jetty.server.Server(new InetSocketAddress(httphost, httpport));
ContextHandlerCollection contexts = new ContextHandlerCollection();
httpserver.setHandler(contexts);
ServletContextHandler contextRoot = new ServletContextHandler(ServletContextHandler.GZIP);
contextRoot.setContextPath("/");
contextRoot.addServlet(new ServletHolder(new PrometheusServlet(statsProvider)), "/metrics");
contexts.addHandler(contextRoot);
File webUi = new File("web/ui");
if (webUi.isDirectory()) {
WebAppContext webApp = new WebAppContext(new File("web/ui").getAbsolutePath(), "/ui");
contexts.addHandler(webApp);
} else {
LOGGER.info("Cannot find " + webUi.getAbsolutePath() + " directory. Web UI will not be deployed");
}
uiurl = "http://" + httpadvertisedhost + ":" + httpadvertisedport + "/ui/#/login?url=" + server.getJdbcUrl();
metricsUrl = "http://" + httpadvertisedhost + ":" + httpadvertisedport + "/metrics";
LOGGER.info("Listening for client (http) connections on " + httphost + ":" + httpport);
httpserver.start();
}
LOGGER.info("HerdDB server starter. Node id " + server.getNodeId());
LOGGER.info("JDBC URL: " + server.getJdbcUrl());
LOGGER.info("Web Interface: " + uiurl);
LOGGER.info("Metrics: " + metricsUrl);
started = true;
}
Aggregations