public JvmMetricSet() { registerSet("jvm.buffers", new BufferPoolMetricSet(getPlatformMBeanServer())); registerSet("jvm.classloading", new ClassLoadingGaugeSet()); registerSet("jvm.fd", new FileDescriptorMetrics()); registerSet("jvm.gc", new GarbageCollectorMetricSet()); registerSet("jvm.memory", new MemoryUsageGaugeSet()); registerSet("jvm.thread", new CachedThreadStatesGaugeSet(60, TimeUnit.SECONDS)); metrics.put("jvm.uptime", new UptimeGauge()); try { metrics.put("jvm.processCPU", new ProcessCpuTicksGauge()); } catch (ClassNotFoundException | IOException e) { LOGGER.error("Error fetching process CPU usage metrics.", e); } }
public CloudWatchReporter build() { if (withJvmMetrics) { metricRegistry.register("jvm.uptime", (Gauge<Long>) () -> ManagementFactory.getRuntimeMXBean().getUptime()); metricRegistry.register("jvm.current_time", (Gauge<Long>) clock::getTime); metricRegistry.register("jvm.classes", new ClassLoadingGaugeSet()); metricRegistry.register("jvm.fd_usage", new FileDescriptorRatioGauge()); metricRegistry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet()); metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet()); metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet()); } cwRateUnit = toStandardUnit(rateUnit); cwDurationUnit = toStandardUnit(durationUnit); return new CloudWatchReporter(this); }
public static void enableJvm() { if (bEnableJvm) return; METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); final JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build(); jmxReporter.start(); bEnableJvm = true; }
@Override public void onStartup(ServletContext servletContext) throws ServletException { metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); servletContext.setAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE, metricRegistry); FilterRegistration.Dynamic metricsFilter = servletContext.addFilter("webappMetricsFilter", new InstrumentedFilter()); metricsFilter.addMappingForUrlPatterns( EnumSet.of(DispatcherType.REQUEST, DispatcherType.FORWARD, DispatcherType.ASYNC), true, "/*"); metricsFilter.setAsyncSupported(true); }
private static void configureJvmMetrics(MetricRegistry registry) { MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); registry.register("jvm.buffer-pool", new BufferPoolMetricSet(mBeanServer)); registry.register("jvm.class-loading", new ClassLoadingGaugeSet()); registry.register("jvm.file-descriptor-ratio", new FileDescriptorRatioGauge()); registry.register("jvm.gc", new GarbageCollectorMetricSet()); registry.register("jvm.memory", new MemoryUsageGaugeSet()); registry.register("jvm.threads", new ThreadStatesGaugeSet()); }
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); if (propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) { log.info("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } }
/** * Adds JVM MetricSets to this engine. By default JVM metrics are not placed in the Registry */ public CodahaleMetricsEngine reportJvmMetrics() { // add JVM metrics if (!jvmMetricsAdded) { metricsCollector.registerAll("JVM-gc", new GarbageCollectorMetricSet()); metricsCollector .registerAll("JVM-buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); metricsCollector.registerAll("JVM-memory", new MemoryUsageGaugeSet()); metricsCollector.registerAll("JVM-threads", new ThreadStatesGaugeSet()); jvmMetricsAdded = true; } return this; }
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JCACHE_STATISTICS, new JCacheGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); if (hikariDataSource != null) { log.debug("Monitoring the datasource"); hikariDataSource.setMetricRegistry(metricRegistry); } if (jHipsterProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } if (jHipsterProperties.getMetrics().getLogs().isEnabled()) { log.info("Initializing Metrics Log reporting"); final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger("metrics")) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(jHipsterProperties.getMetrics().getLogs().getReportFrequency(), TimeUnit.SECONDS); } }
private static void registerSystemMetrics() { REGISTRY.registerAll(new GarbageCollectorMetricSet()); REGISTRY.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); REGISTRY.registerAll(new MemoryUsageGaugeSet()); REGISTRY.registerAll(new ThreadStatesGaugeSet()); register("fd.usage", new FileDescriptorRatioGauge()); }
@Inject public MetricsServlet(final MetricRegistry registry) { super(registry); // JVM metrics are no longer automatically added in codahale-metrics registry.register(name("jvm", "vm"), new JvmAttributeGaugeSet()); registry.register(name("jvm", "memory"), new MemoryUsageGaugeSet()); registry.register(name("jvm", "buffers"), new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); registry.register(name("jvm", "fd_usage"), new FileDescriptorRatioGauge()); registry.register(name("jvm", "thread-states"), new ThreadStatesGaugeSet()); registry.register(name("jvm", "garbage-collectors"), new GarbageCollectorMetricSet()); }
@Override protected void startVerticle() { m_sharedData = vertx.sharedData().getMap(SHARED_METRICS_KEY); // OSHI system information SystemInfo systemInfo = new SystemInfo(); m_oshiMetrics = new OshiMetrics(systemInfo); m_oshiMetrics.init(); // Java OS MXBean information m_osMXBeanMetrics = new OSMXBeanMetrics(); m_osMXBeanMetrics.init(); // Register metrics m_registry = new MetricRegistry(); logger().debug("Registering JVM garbage collection metric set"); registerMetrics("jvm.gc", new GarbageCollectorMetricSet(), m_registry); logger().debug("Registering JMV buffer metric set"); registerMetrics("jvm.buffers", new BufferPoolMetricSet( ManagementFactory.getPlatformMBeanServer()), m_registry); logger().debug("Registering JMV memory usage metric set"); registerMetrics("jvm.memory", new MemoryUsageGaugeSet(), m_registry); logger().debug("Registering JMV thread states metric set"); registerMetrics("jvm.threads", new ThreadStatesGaugeSet(), m_registry); // Aggregate metrics registerAggregateMetrics(m_registry); // Output system information outputSysInfo(systemInfo); }
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); if (jHipsterProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } }
private void registerJVMMetrics() { registerAllJVMMetrics(Level.INFO, "jvm.memory", new MemoryUsageGaugeSet()); registerAllJVMMetrics(Level.INFO, "jvm.os", new OperatingSystemMetricSet()); registerAllJVMMetrics(Level.INFO, "jvm.class-loading", new ClassLoadingGaugeSet()); registerAllJVMMetrics(Level.DEBUG, "jvm.gc", new GarbageCollectorMetricSet()); registerAllJVMMetrics(Level.DEBUG, "jvm.threads", new ThreadStatesGaugeSet()); registerAllJVMMetrics(Level.TRACE, "jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); }
@Provides @Singleton MetricRegistry provideMetrics() { MetricRegistry metrics = new MetricRegistry(); metrics.register("jvm.memory", new MemoryUsageGaugeSet()); metrics.register("jvm.garbage", new GarbageCollectorMetricSet()); metrics.register("jvm.threads", new ThreadStatesGaugeSet()); metrics.register("jvm.files", new FileDescriptorRatioGauge()); metrics.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); return metrics; }
@PostConstruct public void init() { log.debug("Registering JVM gauges"); metricRegistry.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); metricRegistry.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); metricRegistry.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); metricRegistry.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); if (applicationProperties.getMetrics().getJmx().isEnabled()) { log.debug("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(metricRegistry).build(); jmxReporter.start(); } }
@PostConstruct public void init() { log.debug("Registering JVM gauges"); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); METRIC_REGISTRY .register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); if(propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) { log.info("Initializing Metrics JMX reporting"); JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build(); jmxReporter.start(); } }
@PostConstruct public void init() { logger.debug("Registring JVM gauges"); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_MEMORY, new MemoryUsageGaugeSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_GARBAGE, new GarbageCollectorMetricSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_THREADS, new ThreadStatesGaugeSet()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_FILES, new FileDescriptorRatioGauge()); METRIC_REGISTRY.register(PROP_METRIC_REG_JVM_BUFFERS, new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); if (propertyResolver.getProperty(PROP_JMX_ENABLED, Boolean.class, false)) { logger.info("Initializing Metrics JMX reporting"); final JmxReporter jmxReporter = JmxReporter.forRegistry(METRIC_REGISTRY).build(); jmxReporter.start(); } }
public RegisterJVMMetrics(CommandBuilder builder, Config config, Command parent, Command child, final MorphlineContext context) { super(builder, config, parent, child, context); validateArguments(); MetricRegistry registry = context.getMetricRegistry(); BufferPoolMetricSet bufferPoolMetrics = new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()); registerAll("jvm.buffers", bufferPoolMetrics, registry); registerAll("jvm.gc", new GarbageCollectorMetricSet(), registry); registerAll("jvm.memory", new MemoryUsageGaugeSet(), registry); registerAll("jvm.threads", new ThreadStatesGaugeSet(), registry); register("jvm.fileDescriptorCountRatio", new FileDescriptorRatioGauge(), registry); context.getHealthCheckRegistry().register("deadlocks", new ThreadDeadlockHealthCheck()); }
private SentryMetrics() { registerMetricSet("gc", new GarbageCollectorMetricSet(), SentryMetricsServletContextListener.METRIC_REGISTRY); registerMetricSet("buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()), SentryMetricsServletContextListener.METRIC_REGISTRY); registerMetricSet("memory", new MemoryUsageGaugeSet(), SentryMetricsServletContextListener.METRIC_REGISTRY); registerMetricSet("threads", new ThreadStatesGaugeSet(), SentryMetricsServletContextListener.METRIC_REGISTRY); }
protected MetricRegistry configureMetricRegistry() { final MetricRegistry metricRegistry = new MetricRegistry(); metricRegistry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet()); metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet()); metricRegistry.register("jvm.threads", new ThreadStatesGaugeSet()); if (getConfiguration().isJmxEnabled()) { JmxReporter.forRegistry(metricRegistry).build().start(); } return metricRegistry; }
private static void registerSysStats(){ REGISTRY.registerAll(new GarbageCollectorMetricSet()); REGISTRY.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); REGISTRY.registerAll(new MemoryUsageGaugeSet()); REGISTRY.registerAll(new ThreadStatesGaugeSet()); }
private static void registerSysStats(){ REGISTRY.registerAll(scoped("gc", new GarbageCollectorMetricSet())); REGISTRY.registerAll(scoped("buffer-pool", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()))); REGISTRY.registerAll(scoped("memory", new MemoryUsageGaugeSet())); REGISTRY.registerAll(scoped("threads", new ThreadStatesGaugeSet())); }
private void registerMetrics( Application application, MetricRegistry metrics ) { Config config = application.config().atKey( "metrics" ); // JVM Meters if( config.bool( "jvm.bufferpools.enabled" ) ) { metrics.register( "jvm.bufferpools", new BufferPoolMetricSet( getPlatformMBeanServer() ) ); } if( config.bool( "jvm.threadstates.enabled" ) ) { metrics.register( "jvm.threadstates", new ThreadStatesGaugeSet() ); } if( config.bool( "jvm.classloading.enabled" ) ) { metrics.register( "jvm.classloading", new ClassLoadingGaugeSet() ); } if( config.bool( "jvm.garbagecollection.enabled" ) ) { metrics.register( "jvm.garbagecollection", new GarbageCollectorMetricSet() ); } if( config.bool( "jvm.memory.enabled" ) ) { metrics.register( "jvm.memory", new MemoryUsageGaugeSet() ); } if( config.bool( "jvm.filedescriptors.enabled" ) ) { metrics.register( "jvm.filedescriptors.ratio", new FileDescriptorRatioGauge() ); } // Connection & HTTP Metrics requestTimers = new ConcurrentHashMap<>(); eventRegistration = application.events().registerListener( new EventListener( metrics, requestTimers, config.bool( "http.connections.enabled" ), config.bool( "http.requests.enabled" ), config.bool( "http.success.enabled" ), config.bool( "http.redirections.enabled" ), config.bool( "http.client_errors.enabled" ), config.bool( "http.server_errors.enabled" ), config.bool( "http.unknown.enabled" ) ) ); }
static synchronized void init() { if (registery != null) { return; } try { registery = new MetricRegistry(); MBeanServer mbs = ManagementFactory.getPlatformMBeanServer(); registery.registerAll(new BufferPoolMetricSet(mbs)); registery.register("gc", new GarbageCollectorMetricSet()); registery.register( "jvm.memory", new MemoryUsageGaugeSet( ManagementFactory.getMemoryMXBean(), Collections .<MemoryPoolMXBean> emptyList())); if (cfg().getProperty("taskworker.metrics.console", false)) { ConsoleReporter .forRegistry(registery) .build() .start(cfg().getProperty( "taskworker.metrics.console.interval", 30), TimeUnit.SECONDS); } if (cfg().getProperty("taskworker.metrics.graphite", false)) { final Graphite graphite = new Graphite(new InetSocketAddress( cfg().getProperty("taskworker.metrics.graphite.host", "localhost"), Integer.parseInt(cfg() .getProperty( "taskworker.metrics.graphite.port", "2003")))); final GraphiteReporter reporter = GraphiteReporter .forRegistry(registery) .prefixedWith( cfg().getProperty( "taskworker.metrics.graphite.prefix", "localhost")) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .filter(MetricFilter.ALL).build(graphite); reporter.start( cfg().getProperty( "taskworker.metrics.graphite.interval", 30), TimeUnit.SECONDS); logger.info("Started metrics graphite reporter"); } } catch (RuntimeException e) { logger.log(Level.SEVERE, "metrics failed to load", e); throw e; } }
/** * Starts the dashboard. */ @Validate public void start() { logger().info("Registering JVM metrics"); registry.register("jvm.memory", new MemoryUsageGaugeSet()); registry.register("jvm.garbage", new GarbageCollectorMetricSet()); registry.register("jvm.threads", new ThreadStatesGaugeSet()); registry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); registry.register("jvm.cpu", new CpuGaugeSet()); registry.register("jvm.runtime", new RuntimeGaugeSet()); if (configuration.getBooleanWithDefault("monitor.http.enabled", true)) { logger().info("Registering HTTP metrics"); this.httpMetricFilter = new HttpMetricFilter(bc, configuration, registry); httpMetricFilter.start(); } if (configuration.getBooleanWithDefault("monitor.jmx.enabled", true)) { logger().info("Initializing Metrics JMX reporting"); final JmxReporter jmxReporter = JmxReporter.forRegistry(registry).build(); jmxReporter.start(); } if (configuration.getBooleanWithDefault("monitor.graphite.enabled", false)) { logger().info("Initializing Metrics Graphite reporting"); String graphiteHost = configuration.getOrDie("monitor.graphite.host"); int graphitePort = configuration.getIntegerOrDie("monitor.graphite.port"); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(registry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } logger().info("Registering the metric registry as service"); reg = bc.registerService(MetricRegistry.class, registry, null); task = scheduler.scheduleAtFixedRate(new Runnable() { /** * Sends updated data to the websocket. */ public void run() { publisher.publish("/monitor/update", json.toJson(getData())); } }, 0, 10, TimeUnit.SECONDS); }