use of com.codahale.metrics.graphite.Graphite in project flink by splunk.
the class GraphiteReporter method getReporter.
@Override
public ScheduledReporter getReporter(MetricConfig config) {
String host = config.getString(ARG_HOST, null);
int port = config.getInteger(ARG_PORT, -1);
if (host == null || host.length() == 0 || port < 1) {
throw new IllegalArgumentException("Invalid host/port configuration. Host: " + host + " Port: " + port);
}
String prefix = config.getString(ARG_PREFIX, null);
String conversionRate = config.getString(ARG_CONVERSION_RATE, null);
String conversionDuration = config.getString(ARG_CONVERSION_DURATION, null);
String protocol = config.getString(ARG_PROTOCOL, "TCP");
com.codahale.metrics.graphite.GraphiteReporter.Builder builder = com.codahale.metrics.graphite.GraphiteReporter.forRegistry(registry);
if (prefix != null) {
builder.prefixedWith(prefix);
}
if (conversionRate != null) {
builder.convertRatesTo(TimeUnit.valueOf(conversionRate));
}
if (conversionDuration != null) {
builder.convertDurationsTo(TimeUnit.valueOf(conversionDuration));
}
Protocol prot;
try {
prot = Protocol.valueOf(protocol);
} catch (IllegalArgumentException iae) {
log.warn("Invalid protocol configuration: " + protocol + " Expected: TCP or UDP, defaulting to TCP.");
prot = Protocol.TCP;
}
log.info("Configured GraphiteReporter with {host:{}, port:{}, protocol:{}}", host, port, prot);
switch(prot) {
case UDP:
return builder.build(new GraphiteUDP(host, port));
case TCP:
default:
return builder.build(new Graphite(host, port));
}
}
use of com.codahale.metrics.graphite.Graphite in project nosqlbench by nosqlbench.
the class MetricReporters method addGraphite.
public MetricReporters addGraphite(String host, int graphitePort, String globalPrefix) {
logger.debug("Adding graphite reporter to " + host + " with port " + graphitePort + " and prefix " + globalPrefix);
if (metricRegistries.isEmpty()) {
throw new RuntimeException("There are no metric registries.");
}
for (PrefixedRegistry prefixedRegistry : metricRegistries) {
Graphite graphite = new Graphite(new InetSocketAddress(host, graphitePort));
String _prefix = prefixedRegistry.prefix != null ? (!prefixedRegistry.prefix.isEmpty() ? globalPrefix + "." + prefixedRegistry.prefix : globalPrefix) : globalPrefix;
GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(prefixedRegistry.metricRegistry).prefixedWith(_prefix).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.NANOSECONDS).filter(ActivityMetrics.METRIC_FILTER).build(graphite);
scheduledReporters.add(graphiteReporter);
}
return this;
}
use of com.codahale.metrics.graphite.Graphite in project java-apply by javachengwc.
the class MetricsReport method start.
public void start() {
logger.info("MetricsReport report start start.............");
// carbon-relay地址端口
Graphite graphite = new Graphite("0.0.0.0", 2013);
GraphiteReporter jvmReporter = GraphiteReporter.forRegistry(jvmMetrics.getJvmMetrics()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).prefixedWith("reporter.jvm").build(graphite);
jvmReporter.start(1, TimeUnit.SECONDS);
reportSet.add(jvmReporter);
GraphiteReporter reporter = GraphiteReporter.forRegistry(meterMetrics.getMeterMetrics()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).prefixedWith("reporter.meter").build(graphite);
reporter.start(1, TimeUnit.SECONDS);
reportSet.add(reporter);
logger.info("MetricsReport report start end.............");
}
use of com.codahale.metrics.graphite.Graphite in project commafeed by Athou.
the class CommaFeedModule method configure.
@Override
protected void configure() {
CacheService cacheService = config.getApplicationSettings().getCache() == CacheType.NOOP ? new NoopCacheService() : new RedisCacheService(config.getRedisPoolFactory().build());
log.info("using cache {}", cacheService.getClass());
bind(CacheService.class).toInstance(cacheService);
Multibinder<AbstractFaviconFetcher> faviconMultibinder = Multibinder.newSetBinder(binder(), AbstractFaviconFetcher.class);
faviconMultibinder.addBinding().to(YoutubeFaviconFetcher.class);
faviconMultibinder.addBinding().to(FacebookFaviconFetcher.class);
faviconMultibinder.addBinding().to(DefaultFaviconFetcher.class);
Multibinder<FeedURLProvider> urlProviderMultibinder = Multibinder.newSetBinder(binder(), FeedURLProvider.class);
urlProviderMultibinder.addBinding().to(InPageReferenceFeedURLProvider.class);
urlProviderMultibinder.addBinding().to(YoutubeFeedURLProvider.class);
Multibinder<ScheduledTask> taskMultibinder = Multibinder.newSetBinder(binder(), ScheduledTask.class);
taskMultibinder.addBinding().to(OldStatusesCleanupTask.class);
taskMultibinder.addBinding().to(OldEntriesCleanupTask.class);
taskMultibinder.addBinding().to(OrphanedFeedsCleanupTask.class);
taskMultibinder.addBinding().to(OrphanedContentsCleanupTask.class);
ApplicationSettings settings = config.getApplicationSettings();
if (settings.isGraphiteEnabled()) {
final String graphitePrefix = settings.getGraphitePrefix();
final String graphiteHost = settings.getGraphiteHost();
final int graphitePort = settings.getGraphitePort();
final int graphiteInterval = settings.getGraphiteInterval();
log.info("Graphite Metrics will be sent to host={}, port={}, prefix={}, interval={}sec", graphiteHost, graphitePort, graphitePrefix, graphiteInterval);
final Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort));
final GraphiteReporter reporter = GraphiteReporter.forRegistry(metrics).prefixedWith(graphitePrefix).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite);
reporter.start(graphiteInterval, TimeUnit.SECONDS);
} else {
log.info("Graphite Metrics Disabled. Metrics will not be sent.");
}
}
use of com.codahale.metrics.graphite.Graphite in project styx by ExpediaGroup.
the class GraphiteReporterTest method setUp.
@BeforeEach
public void setUp() {
Clock clock = mock(Clock.class);
graphite = mock(Graphite.class);
MetricRegistry registry = mock(MetricRegistry.class);
when(clock.getTime()).thenReturn(TIMESTAMP * 1000);
reporter = forRegistry(registry).withClock(clock).prefixedWith("prefix").convertRatesTo(SECONDS).convertDurationsTo(MILLISECONDS).filter(MetricFilter.ALL).build(graphite);
logging = new LoggingTestSupport(GraphiteReporter.class);
}
Aggregations