use of io.prometheus.client.exporter.MetricsServlet in project incubator-pulsar by apache.
the class ZooKeeperStarter method start.
protected static void start(String[] args, String defaultStatsPort) throws Exception {
// Register basic JVM metrics
DefaultExports.initialize();
// load aspectj-weaver agent for instrumentation
AgentLoader.loadAgentClass(Agent.class.getName(), null);
// Start Jetty to serve stats
int port = Integer.parseInt(System.getProperties().getProperty("stats_server_port", defaultStatsPort));
log.info("Starting ZK stats HTTP server at port {}", port);
InetSocketAddress httpEndpoint = InetSocketAddress.createUnresolved("0.0.0.0", port);
Server server = new Server(httpEndpoint);
ServletContextHandler context = new ServletContextHandler();
context.setContextPath("/");
server.setHandler(context);
context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics");
try {
server.start();
} catch (Exception e) {
log.error("Failed to start HTTP server at port {}. Use \"-Dstats_server_port=1234\" to change port number", port, e);
throw e;
}
// Start the regular ZooKeeper server
QuorumPeerMain.main(args);
}
use of io.prometheus.client.exporter.MetricsServlet in project infrautils by opendaylight.
the class OsgiWebInitializer method init.
@PostConstruct
public void init() throws ServletException, NamespaceException {
MetricsServlet metricsServlet = new MetricsServlet(collectorRegistry);
osgiHttpService.registerServlet(PROMETHEUS_METRICS_URL, metricsServlet, null, null);
LOG.info("Metrics for Prometheus scrape now exposed on: {}", PROMETHEUS_METRICS_URL);
}
Aggregations