com.codahale.metrics.jvm.BufferPoolMetricSet Java Examples

The following examples show how to use com.codahale.metrics.jvm.BufferPoolMetricSet. 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: CloudWatchReporter.java    From codahale-aggregated-metrics-cloudwatch-reporter with MIT License 6 votes vote down vote up
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 = cwMeterUnit.orElse(toStandardUnit(rateUnit));
            cwDurationUnit = toStandardUnit(durationUnit);

            return new CloudWatchReporter(this);
        }
 
Example #2
Source File: DrillMetrics.java    From Bats with Apache License 2.0 5 votes vote down vote up
private static void registerSystemMetrics() {
  REGISTRY.registerAll(new GarbageCollectorMetricSet());
  REGISTRY.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  REGISTRY.registerAll(new MemoryUsageGaugeSet());
  REGISTRY.registerAll(new ThreadStatesGaugeSet());
  REGISTRY.registerAll(new CpuGaugeSet());
  register("fd.usage", new FileDescriptorRatioGauge());
}
 
Example #3
Source File: MetricsConfiguration.java    From flair-engine with Apache License 2.0 5 votes vote down vote up
@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 (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);
    }
}
 
Example #4
Source File: CoreMetrics.java    From styx with Apache License 2.0 5 votes vote down vote up
private static void registerJvmMetrics(MetricRegistry metricRegistry) {
    RuntimeMXBean runtimeMxBean = getRuntimeMXBean();

    MetricRegistry scoped = metricRegistry.scope("jvm");
    scoped.register("bufferpool", new BufferPoolMetricSet(getPlatformMBeanServer()));
    scoped.register("memory", new MemoryUsageGaugeSet());
    scoped.register("thread", new ThreadStatesGaugeSet());
    scoped.register("gc", new GarbageCollectorMetricSet());
    scoped.register("uptime", (Gauge<Long>) runtimeMxBean::getUptime);
    scoped.register("uptime.formatted", (Gauge<String>) () -> formatTime(runtimeMxBean.getUptime()));
    scoped.register("netty", new NettyAllocatorMetricSet("pooled-allocator", PooledByteBufAllocator.DEFAULT.metric()));
    scoped.register("netty", new NettyAllocatorMetricSet("unpooled-allocator", UnpooledByteBufAllocator.DEFAULT.metric()));
}
 
Example #5
Source File: MonitoringModule.java    From curiostack with MIT License 5 votes vote down vote up
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());
}
 
Example #6
Source File: CodahaleMetricsEngine.java    From riposte with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #7
Source File: MetricsServlet.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@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());

  // Export to Prometheus
  new DropwizardExports(registry).register();
}
 
Example #8
Source File: MetricsModule.java    From datacollector with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example #9
Source File: DefaultMetricsService.java    From knox with Apache License 2.0 5 votes vote down vote up
private void registerJvmMetricSets() {
  metrics.registerAll(new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
  metrics.registerAll(new CachedThreadStatesGaugeSet(5, TimeUnit.MINUTES));
  metrics.registerAll(new ClassLoadingGaugeSet());
  metrics.registerAll(new GarbageCollectorMetricSet());
  metrics.registerAll(new JvmAttributeGaugeSet());
  metrics.registerAll(new MemoryUsageGaugeSet());
}
 
Example #10
Source File: SentryMetrics.java    From incubator-sentry with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #11
Source File: RegisterJVMMetricsBuilder.java    From kite with Apache License 2.0 5 votes vote down vote up
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());
}
 
Example #12
Source File: JvmSource.java    From incubator-iotdb with Apache License 2.0 4 votes vote down vote up
public void registerInfo() {
  metricRegistry.register(MetricRegistry.name(sourceName, "gc"), new GarbageCollectorMetricSet());
  metricRegistry.register(MetricRegistry.name(sourceName, "memory"), new MemoryUsageGaugeSet());
  metricRegistry.register(MetricRegistry.name(sourceName, "buffer-pool"),
      new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer()));
}
 
Example #13
Source File: Metrics.java    From dremio-oss with Apache License 2.0 4 votes vote down vote up
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()));
}
 
Example #14
Source File: DashboardExtension.java    From wisdom with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
}