Java 类com.codahale.metrics.jvm.BufferPoolMetricSet 实例源码

项目:JInsight    文件:JvmMetricSet.java   
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);
  }
}
项目:codahale-aggregated-metrics-cloudwatch-reporter    文件:CloudWatchReporter.java   
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);
        }
项目:it-keeps    文件:MetricsFactory.java   
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;
    }
项目:metadatamanagement    文件:MetricsConfiguration.java   
@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);
}
项目:curiostack    文件:MonitoringModule.java   
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());
}
项目:BCDS    文件:MetricsConfiguration.java   
@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();
    }
}
项目:riposte    文件:CodahaleMetricsEngine.java   
/**
 * 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;
}
项目:ehcache3-samples    文件:MetricsConfiguration.java   
@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);
    }
}
项目:drill    文件:DrillMetrics.java   
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());
}
项目:nexus-public    文件:MetricsServlet.java   
@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());
}
项目:spike.x    文件:Activator.java   
@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);
}
项目:lobbycal    文件:MetricsConfiguration.java   
@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();
    }
}
项目:carbon-metrics    文件:MetricManager.java   
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()));
}
项目:datacollector    文件:MetricsModule.java   
@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;
}
项目:p2p-webtv    文件:MetricsConfiguration.java   
@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();
  }
}
项目:agate    文件:MetricsConfiguration.java   
@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();
  }
}
项目:MLDS    文件:MetricsConfiguration.java   
@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();
    }
}
项目:mica2    文件:MetricsConfiguration.java   
@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();
  }
}
项目:cdk    文件:RegisterJVMMetricsBuilder.java   
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());
}
项目:incubator-sentry    文件:SentryMetrics.java   
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);
}
项目:grails-lightweight-deploy    文件:Launcher.java   
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;
}
项目:QDrill    文件:DrillMetrics.java   
private static void registerSysStats(){
  REGISTRY.registerAll(new GarbageCollectorMetricSet());
  REGISTRY.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  REGISTRY.registerAll(new MemoryUsageGaugeSet());
  REGISTRY.registerAll(new ThreadStatesGaugeSet());
}
项目:dremio-oss    文件:Metrics.java   
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()));
}
项目:werval    文件:MetricsPlugin.java   
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" )
        )
    );
}
项目:docproc-jee    文件:Metrics.java   
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;
    }

}
项目:wisdom    文件:DashboardExtension.java   
/**
 * 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);
}