Search in sources :

Example 11 with Graphite

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));
    }
}
Also used : Graphite(com.codahale.metrics.graphite.Graphite) GraphiteUDP(com.codahale.metrics.graphite.GraphiteUDP)

Example 12 with Graphite

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;
}
Also used : InetSocketAddress(java.net.InetSocketAddress) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) Graphite(com.codahale.metrics.graphite.Graphite)

Example 13 with Graphite

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.............");
}
Also used : GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) Graphite(com.codahale.metrics.graphite.Graphite)

Example 14 with Graphite

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.");
    }
}
Also used : RedisCacheService(com.commafeed.backend.cache.RedisCacheService) InetSocketAddress(java.net.InetSocketAddress) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) AbstractFaviconFetcher(com.commafeed.backend.favicon.AbstractFaviconFetcher) ScheduledTask(com.commafeed.backend.task.ScheduledTask) NoopCacheService(com.commafeed.backend.cache.NoopCacheService) ApplicationSettings(com.commafeed.CommaFeedConfiguration.ApplicationSettings) Graphite(com.codahale.metrics.graphite.Graphite) InPageReferenceFeedURLProvider(com.commafeed.backend.urlprovider.InPageReferenceFeedURLProvider) FeedURLProvider(com.commafeed.backend.urlprovider.FeedURLProvider) YoutubeFeedURLProvider(com.commafeed.backend.urlprovider.YoutubeFeedURLProvider) RedisCacheService(com.commafeed.backend.cache.RedisCacheService) CacheService(com.commafeed.backend.cache.CacheService) NoopCacheService(com.commafeed.backend.cache.NoopCacheService)

Example 15 with Graphite

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);
}
Also used : Graphite(com.codahale.metrics.graphite.Graphite) MetricRegistry(com.codahale.metrics.MetricRegistry) Clock(com.codahale.metrics.Clock) LoggingTestSupport(com.hotels.styx.support.matchers.LoggingTestSupport) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

Graphite (com.codahale.metrics.graphite.Graphite)29 InetSocketAddress (java.net.InetSocketAddress)19 GraphiteReporter (com.codahale.metrics.graphite.GraphiteReporter)13 MetricRegistry (com.codahale.metrics.MetricRegistry)9 GraphiteUDP (com.codahale.metrics.graphite.GraphiteUDP)4 TimeUnit (java.util.concurrent.TimeUnit)4 ConsoleReporter (com.codahale.metrics.ConsoleReporter)3 ScheduledReporter (com.codahale.metrics.ScheduledReporter)3 GraphiteSender (com.codahale.metrics.graphite.GraphiteSender)3 ApplicationScoped (javax.enterprise.context.ApplicationScoped)3 Inject (javax.inject.Inject)3 IndyMetricsConfig (org.commonjava.indy.metrics.conf.IndyMetricsConfig)3 IndyMetricsNamed (org.commonjava.indy.metrics.conf.annotation.IndyMetricsNamed)3 ZabbixCacheStorage (org.commonjava.indy.metrics.zabbix.cache.ZabbixCacheStorage)3 IndyZabbixReporter (org.commonjava.indy.metrics.zabbix.reporter.IndyZabbixReporter)3 IndyZabbixSender (org.commonjava.indy.metrics.zabbix.sender.IndyZabbixSender)3 IndyHttpProvider (org.commonjava.indy.subsys.http.IndyHttpProvider)3 PickledGraphite (com.codahale.metrics.graphite.PickledGraphite)2 HostAndPort (com.google.common.net.HostAndPort)2 DropwizardMetricsOptions (io.vertx.ext.dropwizard.DropwizardMetricsOptions)2