Search in sources :

Example 1 with StormMetricsFilter

use of org.apache.storm.metrics2.filters.StormMetricsFilter in project storm by apache.

the class CsvStormReporter method prepare.

@Override
public void prepare(MetricRegistry metricsRegistry, Map<String, Object> topoConf, Map<String, Object> reporterConf) {
    LOG.debug("Preparing...");
    CsvReporter.Builder builder = CsvReporter.forRegistry(metricsRegistry);
    Locale locale = ClientMetricsUtils.getMetricsReporterLocale(reporterConf);
    if (locale != null) {
        builder.formatFor(locale);
    }
    TimeUnit rateUnit = ClientMetricsUtils.getMetricsRateUnit(reporterConf);
    if (rateUnit != null) {
        builder.convertRatesTo(rateUnit);
    }
    TimeUnit durationUnit = ClientMetricsUtils.getMetricsDurationUnit(reporterConf);
    if (durationUnit != null) {
        builder.convertDurationsTo(durationUnit);
    }
    StormMetricsFilter filter = getMetricsFilter(reporterConf);
    if (filter != null) {
        builder.filter(filter);
    }
    // defaults to 10
    reportingPeriod = getReportPeriod(reporterConf);
    // defaults to seconds
    reportingPeriodUnit = getReportPeriodUnit(reporterConf);
    File csvMetricsDir = getCsvLogDir(topoConf, reporterConf);
    reporter = builder.build(csvMetricsDir);
}
Also used : Locale(java.util.Locale) TimeUnit(java.util.concurrent.TimeUnit) CsvReporter(com.codahale.metrics.CsvReporter) File(java.io.File) StormMetricsFilter(org.apache.storm.metrics2.filters.StormMetricsFilter)

Example 2 with StormMetricsFilter

use of org.apache.storm.metrics2.filters.StormMetricsFilter in project storm by apache.

the class ScheduledStormReporter method getMetricsFilter.

public static StormMetricsFilter getMetricsFilter(Map<String, Object> reporterConf) {
    StormMetricsFilter filter = null;
    Map<String, Object> filterConf = (Map<String, Object>) reporterConf.get("filter");
    if (filterConf != null) {
        String clazz = (String) filterConf.get("class");
        if (clazz != null) {
            filter = ReflectionUtils.newInstance(clazz);
            filter.prepare(filterConf);
        }
    }
    return filter;
}
Also used : Map(java.util.Map) StormMetricsFilter(org.apache.storm.metrics2.filters.StormMetricsFilter)

Example 3 with StormMetricsFilter

use of org.apache.storm.metrics2.filters.StormMetricsFilter in project storm by apache.

the class ConsoleStormReporter method init.

private void init(MetricRegistry registry, MetricRegistryProvider metricRegistryProvider, Map<String, Object> reporterConf) {
    LOG.debug("Preparing ConsoleReporter");
    ConsoleReporter.Builder builder = ConsoleReporter.forRegistry(registry);
    builder.outputTo(System.out);
    Locale locale = ClientMetricsUtils.getMetricsReporterLocale(reporterConf);
    if (locale != null) {
        builder.formattedFor(locale);
    }
    TimeUnit rateUnit = ClientMetricsUtils.getMetricsRateUnit(reporterConf);
    if (rateUnit != null) {
        builder.convertRatesTo(rateUnit);
    }
    TimeUnit durationUnit = ClientMetricsUtils.getMetricsDurationUnit(reporterConf);
    if (durationUnit != null) {
        builder.convertDurationsTo(durationUnit);
    }
    StormMetricsFilter filter = getMetricsFilter(reporterConf);
    if (filter != null) {
        builder.filter(filter);
    }
    // defaults to 10
    reportingPeriod = getReportPeriod(reporterConf);
    // defaults to seconds
    reportingPeriodUnit = getReportPeriodUnit(reporterConf);
    ScheduledReporter consoleReporter = builder.build();
    boolean reportDimensions = isReportDimensionsEnabled(reporterConf);
    if (reportDimensions) {
        if (metricRegistryProvider == null) {
            throw new RuntimeException("MetricRegistryProvider is required to enable reporting dimensions");
        }
        if (rateUnit == null) {
            rateUnit = TimeUnit.SECONDS;
        }
        if (durationUnit == null) {
            durationUnit = TimeUnit.MILLISECONDS;
        }
        DimensionalReporter dimensionalReporter = new DimensionalReporter(metricRegistryProvider, consoleReporter, this, "ConsoleDimensionalReporter", filter, rateUnit, durationUnit, null, true);
        reporter = dimensionalReporter;
    } else {
        reporter = consoleReporter;
    }
}
Also used : Locale(java.util.Locale) DimensionalReporter(org.apache.storm.metrics2.DimensionalReporter) ConsoleReporter(com.codahale.metrics.ConsoleReporter) TimeUnit(java.util.concurrent.TimeUnit) ScheduledReporter(com.codahale.metrics.ScheduledReporter) StormMetricsFilter(org.apache.storm.metrics2.filters.StormMetricsFilter)

Example 4 with StormMetricsFilter

use of org.apache.storm.metrics2.filters.StormMetricsFilter in project storm by apache.

the class GraphiteStormReporter method prepare.

@Override
public void prepare(MetricRegistry metricsRegistry, Map<String, Object> topoConf, Map<String, Object> reporterConf) {
    LOG.debug("Preparing...");
    GraphiteReporter.Builder builder = GraphiteReporter.forRegistry(metricsRegistry);
    TimeUnit durationUnit = ClientMetricsUtils.getMetricsDurationUnit(reporterConf);
    if (durationUnit != null) {
        builder.convertDurationsTo(durationUnit);
    }
    TimeUnit rateUnit = ClientMetricsUtils.getMetricsRateUnit(reporterConf);
    if (rateUnit != null) {
        builder.convertRatesTo(rateUnit);
    }
    StormMetricsFilter filter = getMetricsFilter(reporterConf);
    if (filter != null) {
        builder.filter(filter);
    }
    String prefix = getMetricsPrefixedWith(reporterConf);
    if (prefix != null) {
        builder.prefixedWith(prefix);
    }
    // defaults to 10
    reportingPeriod = getReportPeriod(reporterConf);
    // defaults to seconds
    reportingPeriodUnit = getReportPeriodUnit(reporterConf);
    // Not exposed:
    // * withClock(Clock)
    String host = getMetricsTargetHost(reporterConf);
    Integer port = getMetricsTargetPort(reporterConf);
    String transport = getMetricsTargetTransport(reporterConf);
    GraphiteSender sender = null;
    if (transport.equalsIgnoreCase("udp")) {
        sender = new GraphiteUDP(host, port);
    } else {
        sender = new Graphite(host, port);
    }
    reporter = builder.build(sender);
}
Also used : GraphiteSender(com.codahale.metrics.graphite.GraphiteSender) GraphiteReporter(com.codahale.metrics.graphite.GraphiteReporter) Graphite(com.codahale.metrics.graphite.Graphite) TimeUnit(java.util.concurrent.TimeUnit) StormMetricsFilter(org.apache.storm.metrics2.filters.StormMetricsFilter) GraphiteUDP(com.codahale.metrics.graphite.GraphiteUDP)

Example 5 with StormMetricsFilter

use of org.apache.storm.metrics2.filters.StormMetricsFilter in project storm by apache.

the class JmxStormReporter method prepare.

@Override
public void prepare(MetricRegistry metricsRegistry, Map<String, Object> topoConf, Map<String, Object> reporterConf) {
    LOG.info("Preparing...");
    JmxReporter.Builder builder = JmxReporter.forRegistry(metricsRegistry);
    TimeUnit durationUnit = ClientMetricsUtils.getMetricsDurationUnit(reporterConf);
    if (durationUnit != null) {
        builder.convertDurationsTo(durationUnit);
    }
    TimeUnit rateUnit = ClientMetricsUtils.getMetricsRateUnit(reporterConf);
    if (rateUnit != null) {
        builder.convertRatesTo(rateUnit);
    }
    String domain = getMetricsJmxDomain(reporterConf);
    if (domain != null) {
        builder.inDomain(domain);
    }
    StormMetricsFilter filter = ScheduledStormReporter.getMetricsFilter(reporterConf);
    if (filter != null) {
        builder.filter(filter);
    }
    // other builder functions not exposed:
    // * createsObjectNamesWith(ObjectNameFactory onFactory)
    // * registerWith (MBeanServer)
    // * specificDurationUnits (Map<String,TimeUnit> specificDurationUnits)
    // * specificRateUnits(Map<String,TimeUnit> specificRateUnits)
    reporter = builder.build();
}
Also used : TimeUnit(java.util.concurrent.TimeUnit) JmxReporter(com.codahale.metrics.JmxReporter) StormMetricsFilter(org.apache.storm.metrics2.filters.StormMetricsFilter)

Aggregations

StormMetricsFilter (org.apache.storm.metrics2.filters.StormMetricsFilter)5 TimeUnit (java.util.concurrent.TimeUnit)4 Locale (java.util.Locale)2 ConsoleReporter (com.codahale.metrics.ConsoleReporter)1 CsvReporter (com.codahale.metrics.CsvReporter)1 JmxReporter (com.codahale.metrics.JmxReporter)1 ScheduledReporter (com.codahale.metrics.ScheduledReporter)1 Graphite (com.codahale.metrics.graphite.Graphite)1 GraphiteReporter (com.codahale.metrics.graphite.GraphiteReporter)1 GraphiteSender (com.codahale.metrics.graphite.GraphiteSender)1 GraphiteUDP (com.codahale.metrics.graphite.GraphiteUDP)1 File (java.io.File)1 Map (java.util.Map)1 DimensionalReporter (org.apache.storm.metrics2.DimensionalReporter)1