com.codahale.metrics.jvm.FileDescriptorRatioGauge Java Examples
The following examples show how to use
com.codahale.metrics.jvm.FileDescriptorRatioGauge.
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 |
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: TajoSystemMetrics.java From tajo with Apache License 2.0 | 6 votes |
public void start() { setMetricsReporter(metricsGroupName); final String jvmMetricsName = metricsGroupName + "-JVM"; setMetricsReporter(jvmMetricsName); if(!inited) { metricRegistry.register(MetricRegistry.name(jvmMetricsName, "MEMORY"), new MemoryUsageGaugeSet()); metricRegistry.register(MetricRegistry.name(jvmMetricsName, "FILE"), new FileDescriptorRatioGauge()); metricRegistry.register(MetricRegistry.name(jvmMetricsName, "GC"), new GarbageCollectorMetricSet()); metricRegistry.register(MetricRegistry.name(jvmMetricsName, "THREAD"), new ThreadStatesGaugeSet()); metricRegistry.register(MetricRegistry.name(jvmMetricsName, "LOG"), new LogEventGaugeSet()); jmxReporter = JmxReporter.forRegistry(metricRegistry).inDomain("Tajo") .createsObjectNamesWith(new TajoJMXObjectNameFactory()).build(); jmxReporter.start(); } inited = true; }
Example #3
Source File: MetricsConfiguration.java From flair-engine with Apache License 2.0 | 5 votes |
@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: RegisterJVMMetricsBuilder.java From kite with Apache License 2.0 | 5 votes |
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 #5
Source File: JmxJvmMetrics.java From nifi with Apache License 2.0 | 5 votes |
public static JmxJvmMetrics getInstance() { if (metricRegistry.get() == null) { metricRegistry.set(new MetricRegistry()); metricRegistry.get().register(REGISTRY_METRICSET_JVM_ATTRIBUTES, new JvmAttributeGaugeSet()); metricRegistry.get().register(REGISTRY_METRICSET_MEMORY, new MemoryUsageGaugeSet()); metricRegistry.get().register(REGISTRY_METRICSET_THREADS, new ThreadStatesGaugeSet()); metricRegistry.get().register(REGISTRY_METRICSET_GARBAGE_COLLECTORS, new GarbageCollectorMetricSet()); metricRegistry.get().register(OS_FILEDESCRIPTOR_USAGE, new FileDescriptorRatioGauge()); } return new JmxJvmMetrics(); }
Example #6
Source File: SiddhiStreamReporterTest.java From Decision with Apache License 2.0 | 5 votes |
@Test public void testReport() throws Exception { Clock clock= Clock.defaultClock(); reporter= builder.convertRatesTo(TimeUnit.MINUTES) .convertDurationsTo(TimeUnit.SECONDS) .withClock(clock) .filter(MetricFilter.ALL) .build(); reporter.start(1, TimeUnit.SECONDS); SortedMap<String, Gauge> gauges= new TreeMap<>(); SortedMap<String, Counter> counters= new TreeMap<>(); SortedMap<String, Histogram> histograms= new TreeMap<>(); SortedMap<String, Meter> meters= new TreeMap<>(); SortedMap<String, Timer> timers= new TreeMap<>(); Gauge gauge= new FileDescriptorRatioGauge(); gauges.put("gauges", gauge); Counter counter= new Counter(); counters.put("counters", counter); Meter meter= new Meter(); meters.put("meters", meter); Timer timer= new Timer(); timers.put("timers", timer); Exception ex= null; try { reporter.report(gauges, counters, histograms, meters, timers); } catch (Exception e) {ex= e; } assertNull("Expected null value that means not exception", ex); }
Example #7
Source File: ChassisConfiguration.java From chassis with Apache License 2.0 | 5 votes |
/** * Initializes the metrics registry * * @return metric registry bean */ @Bean public MetricRegistry metricRegistry() { final MetricRegistry bean = new MetricRegistry(); // add JVM metrics bean.register("jvm.gc", new GarbageCollectorMetricSet()); bean.register("jvm.memory", new MemoryUsageGaugeSet()); bean.register("jvm.thread-states", new ThreadStatesGaugeSet()); bean.register("jvm.fd", new FileDescriptorRatioGauge()); bean.register("jvm.load-average", new Gauge<Double>() { private OperatingSystemMXBean mxBean = ManagementFactory.getOperatingSystemMXBean(); public Double getValue() { try { return mxBean.getSystemLoadAverage(); } catch (Exception e) { // not supported return -1d; } } }); // add Logback metrics final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory(); final Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME); final InstrumentedAppender appender = new InstrumentedAppender(bean); appender.setContext(root.getLoggerContext()); appender.start(); root.addAppender(appender); return bean; }
Example #8
Source File: MetricsConfiguration.java From chassis with Apache License 2.0 | 5 votes |
/*** * Initializes the metrics registry * * @return metric registry bean */ @Bean public MetricRegistry metricRegistry() { final MetricRegistry bean = new MetricRegistry(); // add JVM metrics bean.register("jvm.gc", new GarbageCollectorMetricSet()); bean.register("jvm.memory", new MemoryUsageGaugeSet()); bean.register("jvm.thread-states", new ThreadStatesGaugeSet()); bean.register("jvm.fd", new FileDescriptorRatioGauge()); return bean; }
Example #9
Source File: JMXReportingService.java From incubator-gobblin with Apache License 2.0 | 5 votes |
private void registerJvmMetrics() { registerMetricSetWithPrefix("jvm.gc", new GarbageCollectorMetricSet()); registerMetricSetWithPrefix("jvm.memory", new MemoryUsageGaugeSet()); registerMetricSetWithPrefix("jvm.threads", new ThreadStatesGaugeSet()); this.metricRegistry.register("jvm.fileDescriptorRatio", new FileDescriptorRatioGauge()); for (Map.Entry<String, MetricSet> metricSet : this.additionalMetricSets.entrySet()) { registerMetricSetWithPrefix(metricSet.getKey(), metricSet.getValue()); } }
Example #10
Source File: TajoSystemMetrics.java From incubator-tajo with Apache License 2.0 | 5 votes |
public void start() { setMetricsReporter(metricsGroupName); String jvmMetricsName = metricsGroupName + "-jvm"; setMetricsReporter(jvmMetricsName); if(!inited) { metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Heap"), new MemoryUsageGaugeSet()); metricRegistry.register(MetricRegistry.name(jvmMetricsName, "File"), new FileDescriptorRatioGauge()); metricRegistry.register(MetricRegistry.name(jvmMetricsName, "GC"), new GarbageCollectorMetricSet()); metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Thread"), new ThreadStatesGaugeSet()); metricRegistry.register(MetricRegistry.name(jvmMetricsName, "Log"), new LogEventGaugeSet()); } inited = true; }
Example #11
Source File: DropWizardJVMMetrics.java From james-project with Apache License 2.0 | 5 votes |
public void start() { metricRegistry.register("jvm.file.descriptor", new FileDescriptorRatioGauge()); metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet()); metricRegistry.register("jvm.threads", new ThreadStatesGaugeSet()); metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet()); metricRegistry.register("jvm.class.loading", new ClassLoadingGaugeSet()); }
Example #12
Source File: MetricsModule.java From datacollector with Apache License 2.0 | 5 votes |
@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 #13
Source File: MetricsServlet.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@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 #14
Source File: MeterConfiguration.java From haven-platform with Apache License 2.0 | 5 votes |
@Override public void configureReporters(MetricRegistry metricRegistry) { metricRegistry.addListener(metricsListener); metricRegistry.register("jvm.gc", new GarbageCollectorMetricSet()); metricRegistry.register("jvm.memory", new MemoryUsageGaugeSet()); metricRegistry.register("jvm.thread-states", new ThreadStatesGaugeSet()); metricRegistry.register("jvm.fd.usage", new FileDescriptorRatioGauge()); if(environment.acceptsProfiles(AmqpUtils.PROFILE)) { final String applicationId = AppInfo.getApplicationName(); AmqpUtils.ExchangeFactory exchangeFactory = new AmqpUtils.ExchangeFactory(); exchangeFactory.setExchangeName(exchange); AmqpReporter amqpReporter = AmqpReporter.forRegistry(metricRegistry) .connectionFactoryProvider(connectionFactoryProvider) .exchangeName(exchange) .routingKey(applicationId) .exchangeFactory(exchangeFactory) .build(); amqpReporter.start(reportPeriod, TimeUnit.SECONDS); LOG.info("AmqpReporter enabled: applicationId: {} reportPeriod: {} seconds, exchange: {}", applicationId, reportPeriod, exchange); } else { //sample configuration for metrics reported // https://dropwizard.github.io/metrics/3.1.0/manual/core/#man-core-reporters-console final Slf4jReporter reporter = Slf4jReporter.forRegistry(metricRegistry) .outputTo(LoggerFactory.getLogger("com.codeabovelab.dm.metrics")) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(); reporter.start(reportPeriod, TimeUnit.SECONDS); } }
Example #15
Source File: GraphiteMetrics.java From replicator with Apache License 2.0 | 5 votes |
@Override protected ScheduledReporter getReporter(Map<String, Object> configuration, MetricRegistry registry) { Object namespace = configuration.get(Configuration.GRAPHITE_NAMESPACE); Object hostname = configuration.get(Configuration.GRAPHITE_HOSTNAME); Object port = configuration.get(Configuration.GRAPHITE_PORT); Objects.requireNonNull(namespace, String.format("Configuration required: %s", Configuration.GRAPHITE_NAMESPACE)); Objects.requireNonNull(hostname, String.format("Configuration required: %s", Configuration.GRAPHITE_HOSTNAME)); Objects.requireNonNull(port, String.format("Configuration required: %s", Configuration.GRAPHITE_PORT)); registry.register(MetricRegistry.name("jvm", "gc"), new GarbageCollectorMetricSet()); registry.register(MetricRegistry.name("jvm", "threads"), new ThreadStatesGaugeSet()); registry.register(MetricRegistry.name("jvm", "classes"), new ClassLoadingGaugeSet()); registry.register(MetricRegistry.name("jvm", "fd"), new FileDescriptorRatioGauge()); registry.register(MetricRegistry.name("jvm", "memory"), new MemoryUsageGaugeSet()); ScheduledReporter reporter = GraphiteReporter .forRegistry(registry) .prefixedWith(namespace.toString()) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.SECONDS) .build(new Graphite(new InetSocketAddress(hostname.toString(), Integer.parseInt(port.toString())))); reporter.start(1L, TimeUnit.MINUTES); return reporter; }
Example #16
Source File: MonitoringModule.java From curiostack with MIT License | 5 votes |
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 #17
Source File: OneOpsMetrics.java From oneops with Apache License 2.0 | 5 votes |
/** * Add metrics JVM gauges. */ private void addJvmMetrics() { if (getB("jvm.gcstats", false)) { ooMetricsRegistry.registerAll(new GarbageCollectorMetricSet()); } if (getB("jvm.memory", false)) { ooMetricsRegistry.registerAll(new MemoryUsageGaugeSet()); } if (getB("jvm.threadstate", false)) { ooMetricsRegistry.registerAll(new ThreadStatesGaugeSet()); } if (getB("jvm.filedescriptor", false)) { ooMetricsRegistry.register("openfd.ratio", new FileDescriptorRatioGauge()); } }
Example #18
Source File: MetricsManager.java From emissary with Apache License 2.0 | 5 votes |
protected void initMetrics() { if (this.conf.findBooleanEntry("JVM_METRICS_ENABLED", false)) { logger.debug("JVM Metrics are enabled"); this.metrics.registerAll(new MemoryUsageGaugeSet()); this.metrics.registerAll(new GarbageCollectorMetricSet()); this.metrics.registerAll(new ThreadStatesGaugeSet()); this.metrics.register("file.descriptor.info", new FileDescriptorRatioGauge()); } else { logger.debug("JVM Metrics are disabled"); } }
Example #19
Source File: DrillMetrics.java From Bats with Apache License 2.0 | 5 votes |
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 #20
Source File: MetricSystemTest.java From eagle with Apache License 2.0 | 4 votes |
@Test public void testMetricEvent() { MetricEvent metricEvent = MetricEvent.of("test").build(); Assert.assertEquals(metricEvent.get("name"), "test"); Assert.assertNotNull(metricEvent.get("timestamp")); metricEvent = MetricEvent.of("test1").build(); metricEvent.put("timestamp", 1); Assert.assertEquals(metricEvent.get("name"), "test1"); Assert.assertEquals(metricEvent.get("timestamp"), 1); Counter counter = new Counter(); counter.inc(10); metricEvent = MetricEvent.of("testcount").from(counter).build(); Assert.assertEquals(metricEvent.get("count"), 10l); Gauge gauge = Mockito.mock(FileDescriptorRatioGauge.class); Mockito.when(gauge.getValue()).thenReturn(new Double("0.4")); metricEvent = MetricEvent.of("testGauge").from(gauge).build(); Assert.assertEquals(metricEvent.get("value"), 0.4); //Histogram Histogram histogram = Mockito.mock(Histogram.class); Snapshot snapshot = Mockito.mock(Snapshot.class); Mockito.when(histogram.getCount()).thenReturn(11l); Mockito.when(histogram.getSnapshot()).thenReturn(snapshot); Mockito.when(snapshot.getMin()).thenReturn(1l); Mockito.when(snapshot.getMax()).thenReturn(2l); Mockito.when(snapshot.getMean()).thenReturn(3d); Mockito.when(snapshot.getStdDev()).thenReturn(4d); Mockito.when(snapshot.getMedian()).thenReturn(5d); Mockito.when(snapshot.get75thPercentile()).thenReturn(6d); Mockito.when(snapshot.get95thPercentile()).thenReturn(7d); Mockito.when(snapshot.get98thPercentile()).thenReturn(8d); Mockito.when(snapshot.get99thPercentile()).thenReturn(9d); Mockito.when(snapshot.get999thPercentile()).thenReturn(10d); metricEvent = MetricEvent.of("testHistogram").from(histogram).build(); Assert.assertEquals(metricEvent.get("count"), 11l); Assert.assertEquals(metricEvent.get("min"), 1l); Assert.assertEquals(metricEvent.get("max"), 2l); Assert.assertEquals(metricEvent.get("mean"), 3d); Assert.assertEquals(metricEvent.get("stddev"), 4d); Assert.assertEquals(metricEvent.get("median"), 5d); Assert.assertEquals(metricEvent.get("75thPercentile"), 6d); Assert.assertEquals(metricEvent.get("95thPercentile"), 7d); Assert.assertEquals(metricEvent.get("98thPercentile"), 8d); Assert.assertEquals(metricEvent.get("99thPercentile"), 9d); Assert.assertEquals(metricEvent.get("999thPercentile"), 10d); //Meter Meter meter = Mockito.mock(Meter.class); Mockito.when(meter.getCount()).thenReturn(1l); Mockito.when(meter.getOneMinuteRate()).thenReturn(2d); Mockito.when(meter.getFiveMinuteRate()).thenReturn(3d); Mockito.when(meter.getFifteenMinuteRate()).thenReturn(4d); Mockito.when(meter.getMeanRate()).thenReturn(5d); metricEvent = MetricEvent.of("testMeter").from(meter).build(); Assert.assertEquals(metricEvent.get("value"), 1l); Assert.assertEquals(metricEvent.get("1MinRate"), 2d); Assert.assertEquals(metricEvent.get("5MinRate"), 3d); Assert.assertEquals(metricEvent.get("15MinRate"), 4d); Assert.assertEquals(metricEvent.get("mean"), 5d); //Timer Timer value = Mockito.mock(Timer.class); Mockito.when(value.getCount()).thenReturn(1l); Mockito.when(value.getOneMinuteRate()).thenReturn(2d); Mockito.when(value.getFiveMinuteRate()).thenReturn(3d); Mockito.when(value.getFifteenMinuteRate()).thenReturn(4d); Mockito.when(value.getMeanRate()).thenReturn(5d); metricEvent = MetricEvent.of("testTimer").from(value).build(); Assert.assertEquals(metricEvent.get("value"), 1l); Assert.assertEquals(metricEvent.get("1MinRate"), 2d); Assert.assertEquals(metricEvent.get("5MinRate"), 3d); Assert.assertEquals(metricEvent.get("15MinRate"), 4d); Assert.assertEquals(metricEvent.get("mean"), 5d); }
Example #21
Source File: FileDescriptorGaugeSet.java From semantic-metrics with Apache License 2.0 | 4 votes |
public FileDescriptorGaugeSet() { fileDescriptorRatioGauge = new FileDescriptorRatioGauge(); }