Search in sources :

Example 1 with Graphite

use of com.codahale.metrics.graphite.Graphite in project indy by Commonjava.

the class ReporterIntializer method initGraphiteReporterForHealthCheckMetric.

private void initGraphiteReporterForHealthCheckMetric(MetricRegistry metrics, IndyMetricsConfig config) {
    final Graphite graphite = new Graphite(new InetSocketAddress(config.getGrphiterHostName(), config.getGrphiterPort()));
    final GraphiteReporter reporter = GraphiteReporter.forRegistry(metrics).prefixedWith(config.getGrphiterPrefix()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter((name, metric) -> {
        if (!name.contains(FILTER_SIMPLE) && name.contains(FILTER_HEALTHCHECK)) {
            return true;
        }
        return false;
    }).build(graphite);
    reporter.start(config.getGrphiterHealthcheckPeriod(), TimeUnit.SECONDS);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) ZabbixCacheStorage(org.commonjava.indy.metrics.zabbix.cache.ZabbixCacheStorage) IndyMetricsConfig(org.commonjava.indy.metrics.conf.IndyMetricsConfig) IndyZabbixSender(org.commonjava.indy.metrics.zabbix.sender.IndyZabbixSender) Graphite(com.codahale.metrics.graphite.Graphite) InetSocketAddress(java.net.InetSocketAddress) IndyHttpProvider(org.commonjava.indy.subsys.http.IndyHttpProvider) Inject(javax.inject.Inject) TimeUnit(java.util.concurrent.TimeUnit) IndyZabbixReporter(org.commonjava.indy.metrics.zabbix.reporter.IndyZabbixReporter) IndyMetricsNamed(org.commonjava.indy.metrics.conf.annotation.IndyMetricsNamed) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) ConsoleReporter(com.codahale.metrics.ConsoleReporter) ApplicationScoped(javax.enterprise.context.ApplicationScoped) InetSocketAddress(java.net.InetSocketAddress) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) Graphite(com.codahale.metrics.graphite.Graphite)

Example 2 with Graphite

use of com.codahale.metrics.graphite.Graphite in project indy by Commonjava.

the class ReporterIntializer method initGraphiteReporterForSimpleMetric.

private void initGraphiteReporterForSimpleMetric(MetricRegistry metrics, IndyMetricsConfig config) {
    final Graphite graphite = new Graphite(new InetSocketAddress(config.getGrphiterHostName(), config.getGrphiterPort()));
    final GraphiteReporter reporter = GraphiteReporter.forRegistry(metrics).prefixedWith(config.getGrphiterPrefix()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter((name, metric) -> {
        if (name.contains(FILTER_SIMPLE)) {
            return true;
        }
        return false;
    }).build(graphite);
    reporter.start(config.getGrphiterSimplePriod(), TimeUnit.SECONDS);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) ZabbixCacheStorage(org.commonjava.indy.metrics.zabbix.cache.ZabbixCacheStorage) IndyMetricsConfig(org.commonjava.indy.metrics.conf.IndyMetricsConfig) IndyZabbixSender(org.commonjava.indy.metrics.zabbix.sender.IndyZabbixSender) Graphite(com.codahale.metrics.graphite.Graphite) InetSocketAddress(java.net.InetSocketAddress) IndyHttpProvider(org.commonjava.indy.subsys.http.IndyHttpProvider) Inject(javax.inject.Inject) TimeUnit(java.util.concurrent.TimeUnit) IndyZabbixReporter(org.commonjava.indy.metrics.zabbix.reporter.IndyZabbixReporter) IndyMetricsNamed(org.commonjava.indy.metrics.conf.annotation.IndyMetricsNamed) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) ConsoleReporter(com.codahale.metrics.ConsoleReporter) ApplicationScoped(javax.enterprise.context.ApplicationScoped) InetSocketAddress(java.net.InetSocketAddress) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) Graphite(com.codahale.metrics.graphite.Graphite)

Example 3 with Graphite

use of com.codahale.metrics.graphite.Graphite in project hono by eclipse.

the class MetricConfig method graphiteReporter.

/**
 * Gets a new instance for a graphite reporter.
 *
 * @param period The period to publish the state in milliseconds.
 * @param host The host to report to.
 * @param port The port to report to.
 * @param prefix The prefix used when reporting.
 *
 * @return The new graphite reporter instance.
 */
@Bean
@ConditionalOnProperty(prefix = "hono.metric.reporter.graphite", name = "active", havingValue = "true")
public GraphiteReporter graphiteReporter(@Value("${hono.metric.reporter.graphite.period:5000}") final Long period, @Value("${hono.metric.reporter.graphite.host:localhost}") final String host, @Value("${hono.metric.reporter.graphite.port:2003}") final Integer port, @Value("${hono.metric.reporter.graphite.prefix:}") final String prefix) {
    final Graphite graphite = new Graphite(new InetSocketAddress(host, port));
    String processedPrefix = prefix;
    if (processedPrefix.isEmpty()) {
        try {
            processedPrefix = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException exception) {
            processedPrefix = UNKNOWN;
        }
    }
    LOG.info("metrics - graphite reporter activated: {}:{}  prefix: {}  period: {}", host, port, processedPrefix, period);
    final GraphiteReporter reporter = GraphiteReporter.forRegistry(metricRegistry).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).prefixedWith(processedPrefix).build(graphite);
    reporter.start(period, TimeUnit.MILLISECONDS);
    return reporter;
}
Also used : UnknownHostException(java.net.UnknownHostException) InetSocketAddress(java.net.InetSocketAddress) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) Graphite(com.codahale.metrics.graphite.Graphite) Bean(org.springframework.context.annotation.Bean) ConditionalOnProperty(org.springframework.boot.autoconfigure.condition.ConditionalOnProperty)

Example 4 with Graphite

use of com.codahale.metrics.graphite.Graphite in project pravega by pravega.

the class StatsProviderImpl method start.

@Synchronized
@Override
public void start() {
    init();
    if (conf.isEnableCSVReporter()) {
        // NOTE:  metrics output files are exclusive to a given process
        File outdir;
        if (!Strings.isNullOrEmpty(conf.getMetricsPrefix())) {
            outdir = new File(conf.getCsvEndpoint(), conf.getMetricsPrefix());
        } else {
            outdir = new File(conf.getCsvEndpoint());
        }
        outdir.mkdirs();
        log.info("Configuring stats with csv output to directory [{}]", outdir.getAbsolutePath());
        reporters.add(CsvReporter.forRegistry(getMetrics()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(outdir));
    }
    if (conf.isEnableStatsdReporter()) {
        log.info("Configuring stats with statsD at {}:{}", conf.getStatsDHost(), conf.getStatsDPort());
        reporters.add(StatsDReporter.forRegistry(getMetrics()).build(conf.getStatsDHost(), conf.getStatsDPort()));
    }
    if (conf.isEnableGraphiteReporter()) {
        log.info("Configuring stats with graphite at {}:{}", conf.getGraphiteHost(), conf.getGraphitePort());
        final Graphite graphite = new Graphite(new InetSocketAddress(conf.getGraphiteHost(), conf.getGraphitePort()));
        reporters.add(GraphiteReporter.forRegistry(getMetrics()).prefixedWith(conf.getMetricsPrefix()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).build(graphite));
    }
    if (conf.isEnableJMXReporter()) {
        log.info("Configuring stats with jmx {}", conf.getJmxDomain());
        final JmxReporter jmx = JmxReporter.forRegistry(getMetrics()).inDomain(conf.getJmxDomain()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build();
        jmx.start();
    }
    if (conf.isEnableGangliaReporter()) {
        try {
            log.info("Configuring stats with ganglia at {}:{}", conf.getGangliaHost(), conf.getGangliaPort());
            final GMetric ganglia = new GMetric(conf.getGangliaHost(), conf.getGangliaPort(), GMetric.UDPAddressingMode.MULTICAST, 1);
            reporters.add(GangliaReporter.forRegistry(getMetrics()).prefixedWith(conf.getMetricsPrefix()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build(ganglia));
        } catch (IOException e) {
            log.warn("ganglia create failure: {}", e);
        }
    }
    if (conf.isEnableConsoleReporter()) {
        log.info("Configuring console reporter");
        reporters.add(ConsoleReporter.forRegistry(getMetrics()).convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).build());
    }
    for (ScheduledReporter r : reporters) {
        r.start(conf.getStatsOutputFrequencySeconds(), TimeUnit.SECONDS);
    }
}
Also used : GMetric(info.ganglia.gmetric4j.gmetric.GMetric) InetSocketAddress(java.net.InetSocketAddress) Graphite(com.codahale.metrics.graphite.Graphite) IOException(java.io.IOException) ScheduledReporter(com.codahale.metrics.ScheduledReporter) File(java.io.File) JmxReporter(com.codahale.metrics.JmxReporter) Synchronized(lombok.Synchronized)

Example 5 with Graphite

use of com.codahale.metrics.graphite.Graphite in project knox by apache.

the class GraphiteMetricsReporter method init.

@Override
public void init(GatewayConfig config) throws MetricsReporterException {
    if (config.isMetricsEnabled() && config.isGraphiteMetricsReportingEnabled()) {
        graphite = new Graphite(new InetSocketAddress(config.getGraphiteHost(), config.getGraphitePort()));
        reportingFrequency = config.getGraphiteReportingFrequency();
        setEnabled(true);
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) Graphite(com.codahale.metrics.graphite.Graphite)

Aggregations

Graphite (com.codahale.metrics.graphite.Graphite)19 InetSocketAddress (java.net.InetSocketAddress)14 GraphiteReporter (com.codahale.metrics.graphite.GraphiteReporter)9 MetricRegistry (com.codahale.metrics.MetricRegistry)6 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 File (java.io.File)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 GraphiteUDP (com.codahale.metrics.graphite.GraphiteUDP)2 PickledGraphite (com.codahale.metrics.graphite.PickledGraphite)2 HostAndPort (com.google.common.net.HostAndPort)2