Created
May 23, 2016 08:50
-
-
Save yinjae/801096cd2564ef9605f7e808c19a5abf to your computer and use it in GitHub Desktop.
graphite reporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GraphiteReporter reporter = GraphiteReporter.forRegistry(metricRegistry()) | |
.prefixedWith(getHostname()).convertRatesTo(TimeUnit.SECONDS) | |
.convertDurationsTo(TimeUnit.MILLISECONDS) | |
.filter((name, metric) -> !name.toLowerCase().contains("servo")) | |
.build(new Graphite(new InetSocketAddress("sv-graphite.idincu.net", 2003))); | |
reporter.start(1, TimeUnit.MINUTES); | |
private MetricRegistry metricRegistry() { | |
MetricRegistry registry = new MetricRegistry(); | |
registry.register("custom.gc", new GarbageCollectorMetricSet()); | |
registry.register("custom.class", new ClassLoadingGaugeSet()); | |
registry.register("custom.file", new FileDescriptorRatioGauge()); | |
registry.register("custom.memory", new MemoryUsageGaugeSet()); | |
registry.register("custom.thread.status", new ThreadStatesGaugeSet()); | |
return registry; | |
} | |
private String getHostname() { | |
try { | |
return InetAddress.getLocalHost().getHostName(); | |
} catch (UnknownHostException e) { | |
return "unknownHost"; | |
} | |
} | |
build.gradle | |
compile group: 'io.dropwizard.metrics', name: 'metrics-jvm', version: '3.1.2' | |
compile 'io.dropwizard.metrics:metrics-graphite:3.1.2' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment