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);
}
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;
}
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;
}
}
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);
}
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();
}
Aggregations