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