Java Code Examples for io.prometheus.client.hotspot.DefaultExports#initialize()
The following examples show how to use
io.prometheus.client.hotspot.DefaultExports#initialize() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrometheusService.java From canal with Apache License 2.0 | 8 votes |
@Override public void initialize() { try { logger.info("Start prometheus HTTPServer on port {}.", port); //TODO 2.Https? server = new HTTPServer(port); } catch (IOException e) { logger.warn("Unable to start prometheus HTTPServer.", e); return; } try { // JVM exports DefaultExports.initialize(); instanceExports.initialize(); if (!clientProfiler.isStart()) { clientProfiler.start(); } profiler().setInstanceProfiler(clientProfiler); } catch (Throwable t) { logger.warn("Unable to initialize server exports.", t); } running = true; }
Example 2
Source File: TxleMetrics.java From txle with Apache License 2.0 | 6 votes |
public TxleMetrics(String promMetricsPort) { try { DefaultExports.initialize(); // Default port logic: the default port 8099 has been configured in application.yaml, thus if it's not 8099, then indicate that someone edited it automatically. if (promMetricsPort != null && promMetricsPort.length() > 0) { int metricsPort = Integer.parseInt(promMetricsPort); if (metricsPort > 0) { // Initialize Prometheus's Metrics Server. // To establish the metrics server immediately without checking the port status. new HTTPServer(metricsPort); isEnableMonitorServer = true; } } this.register(); } catch (IOException e) { log.error("Initialize txle metrics server exception, please check the port " + promMetricsPort + ". " + e); } }
Example 3
Source File: JavaSimple.java From java_examples with Apache License 2.0 | 6 votes |
public static void main( String[] args ) throws Exception { Server server = new Server(1234); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); server.setHandler(context); // Expose our example servlet. context.addServlet(new ServletHolder(new ExampleServlet()), "/"); // Expose Promtheus metrics. context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics"); // Add metrics about CPU, JVM memory etc. DefaultExports.initialize(); // Start the webserver. server.start(); server.join(); }
Example 4
Source File: PrometheusMetrics.java From Lavalink with MIT License | 6 votes |
public PrometheusMetrics() { InstrumentedAppender prometheusAppender = new InstrumentedAppender(); //log metrics final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory(); final ch.qos.logback.classic.Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME); prometheusAppender.setContext(root.getLoggerContext()); prometheusAppender.start(); root.addAppender(prometheusAppender); //jvm (hotspot) metrics DefaultExports.initialize(); //gc pause buckets final GcNotificationListener gcNotificationListener = new GcNotificationListener(); for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans()) { if (gcBean instanceof NotificationEmitter) { ((NotificationEmitter) gcBean).addNotificationListener(gcNotificationListener, null, gcBean); } } log.info("Prometheus metrics set up"); }
Example 5
Source File: OMetricsModule.java From Orienteer with Apache License 2.0 | 6 votes |
@Override public void onInitialize(OrienteerWebApplication app, ODatabaseDocument db) { super.onInitialize(app, db); DefaultExports.initialize(); OMetricsRequestCycleListener.install(app); OMetricSessionListener.install(app); new OMetricsOrientDB().register(); // OPerformanceStatisticManager psm = OMetricsOrientDB.getPerformanceStatisticManager(); //WorkAround to avoid NPEs in logs //TODO: Remove when https://github.com/orientechnologies/orientdb/issues/9169 will be fixed // psm.startThreadMonitoring(); // psm.getSessionPerformanceStatistic().startWALFlushTimer(); // psm.getSessionPerformanceStatistic().stopWALFlushTimer(); // psm.stopThreadMonitoring(); //End of block to delete after issue fixing // psm.startMonitoring(); app.mountPackage(OMetricsModule.class.getPackage().getName()); }
Example 6
Source File: PrometheusExporter.java From tunnel with Apache License 2.0 | 5 votes |
@Override public void startup() { PrometheusStatsCollector.createAndRegister(); DefaultExports.initialize(); try { this.server = new HTTPServer(this.exporterConfig.getExportPort()); } catch (Exception e) { // } }
Example 7
Source File: PrometheusServer.java From cineast with MIT License | 5 votes |
public static synchronized void initialize() { if (initalized) { LOGGER.info("Prometheus already initalized"); return; } if (!Config.sharedConfig().getMonitoring().enablePrometheus) { LOGGER.info("Prometheus monitoring not enabled"); return; } DefaultExports.initialize(); Integer port = Config.sharedConfig().getMonitoring().prometheusPort; LOGGER.info("Initalizing Prometheus endpoint at port {}", port); server = Optional.of(new Server(port)); ServletContextHandler context = new ServletContextHandler(); context.setContextPath("/"); server.get().setHandler(context); context.addServlet(new ServletHolder(new MetricsServlet()), "/metrics"); PrometheusExtractionTaskMonitor.init(); ImportTaskMonitor.init(); DatabaseHealthMonitor.init(); RetrievalTaskMonitor.init(); try { server.get().start(); } catch (Exception e) { e.printStackTrace(); } initalized = true; }
Example 8
Source File: PrometheusMetricsTrackerManager.java From soul with Apache License 2.0 | 5 votes |
private void register(final String jmxConfig) { if (!registered.compareAndSet(false, true)) { return; } new BuildInfoCollector().register(); try { new JmxCollector(jmxConfig).register(); DefaultExports.initialize(); } catch (MalformedObjectNameException e) { log.error("init jxm collector error", e); } }
Example 9
Source File: JavaGraphiteBridge.java From java_examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { // Add metrics about CPU, JVM memory etc. DefaultExports.initialize(); Graphite g = new Graphite("localhost", 2003); // Send to graphite every 60s. Thread thread = g.start(CollectorRegistry.defaultRegistry, 60); thread.join(); // Waits forever. }
Example 10
Source File: PrometheusAutoConfiguration.java From orders with Apache License 2.0 | 5 votes |
@Bean @ConditionalOnMissingBean(name = "prometheusMetricsServletRegistrationBean") ServletRegistrationBean prometheusMetricsServletRegistrationBean(@Value("${prometheus.metrics" + ".path:/metrics}") String metricsPath) { DefaultExports.initialize(); return new ServletRegistrationBean(new MetricsServlet(), metricsPath); }
Example 11
Source File: PromMetricsExporter.java From vertx-mqtt-broker with Apache License 2.0 | 5 votes |
@Override public void start() throws Exception { JsonObject conf = config().getJsonObject("prometheus_exporter", new JsonObject()); int httpPort = conf.getInteger("port", 9100); String path = conf.getString("path", "/metrics"); DefaultExports.initialize(); Router router = Router.router(vertx); router.route(path).handler(new MetricsHandler()); vertx.createHttpServer().requestHandler(router::handle).listen(httpPort); }
Example 12
Source File: Metrics.java From FlareBot with MIT License | 5 votes |
public Metrics() { DefaultExports.initialize(); new BotCollector(new BotMetrics()).register(); try { server = new HTTPServer(9191); logger.info("Setup HTTPServer for Metrics"); } catch (IOException e) { throw new IllegalStateException("Failed to set up HTTPServer for Metrics", e); } }
Example 13
Source File: PrometheusTelemetryProvider.java From skywalking with Apache License 2.0 | 5 votes |
@Override public void prepare() throws ServiceNotProvidedException, ModuleStartException { this.registerServiceImplementation(MetricsCreator.class, new PrometheusMetricsCreator()); this.registerServiceImplementation(MetricsCollector.class, new MetricsCollectorNoop()); try { new HTTPServer(config.getHost(), config.getPort()); } catch (IOException e) { throw new ModuleStartException(e.getMessage(), e); } DefaultExports.initialize(); }
Example 14
Source File: App.java From modeldb with Apache License 2.0 | 4 votes |
@Bean public ServletRegistrationBean<MetricsServlet> servletRegistrationBean() { DefaultExports.initialize(); return new ServletRegistrationBean<>(new MetricsServlet(), "/metrics"); }
Example 15
Source File: Application.java From sqs-exporter with Apache License 2.0 | 4 votes |
private void go() throws Exception { DefaultExports.initialize(); new Sqs().register(); Server server = new Server(9384); ServletHandler handler = new ServletHandler(); server.setHandler(handler); handler.addServletWithMapping(IndexServlet.class, "/"); handler.addServletWithMapping(MetricsServlet.class, "/metrics"); handler.addFilterWithMapping(DisableMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)); server.start(); logger.info("Exporter has started."); startup.inc(); HttpGenerator.setJettyVersion(""); server.join(); }
Example 16
Source File: MetricCollectorImpl.java From prom-confluence-exporter with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void afterPropertiesSet() { this.registry.register(this); DefaultExports.initialize(); }
Example 17
Source File: MetricCollectorImpl.java From jira-prometheus-exporter with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void afterPropertiesSet() { this.registry.register(this); DefaultExports.initialize(); }
Example 18
Source File: Metrics.java From javametrics with Apache License 2.0 | 4 votes |
public Metrics() { // Add the default Java collectors DefaultExports.initialize(); // Connect to javametrics Javametrics.getInstance().addListener(listener); }
Example 19
Source File: InstrumentationConfig.java From feast with Apache License 2.0 | 4 votes |
@Bean public ServletRegistrationBean servletRegistrationBean() { DefaultExports.initialize(); return new ServletRegistrationBean(new MetricsServlet(), "/metrics"); }
Example 20
Source File: CryptotraderImpl.java From cryptotrader with GNU Affero General Public License v3.0 | 3 votes |
@Inject public CryptotraderImpl(Injector injector) { this.injector = injector; DefaultExports.initialize(); }