Java Code Examples for com.codahale.metrics.graphite.GraphiteReporter#start()
The following examples show how to use
com.codahale.metrics.graphite.GraphiteReporter#start() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JbootGraphiteReporter.java From jboot with Apache License 2.0 | 6 votes |
@Override public void report(MetricRegistry metricRegistry) { JbootMetricGraphiteReporterConfig config = Jboot.config(JbootMetricGraphiteReporterConfig.class); if (StrUtil.isBlank(config.getHost())) { throw new NullPointerException("graphite reporter host must not be null, please config jboot.metrics.reporter.graphite.host in you properties."); } if (config.getPort() == null) { throw new NullPointerException("graphite reporter port must not be null, please config jboot.metrics.reporter.graphite.port in you properties."); } if (config.getPrefixedWith() == null) { throw new NullPointerException("graphite reporter prefixedWith must not be null, please config jboot.metrics.reporter.graphite.prefixedWith in you properties."); } Graphite graphite = new Graphite(new InetSocketAddress(config.getHost(), config.getPort())); GraphiteReporter reporter = GraphiteReporter.forRegistry(metricRegistry) .prefixedWith(config.getPrefixedWith()) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .filter(MetricFilter.ALL) .build(graphite); reporter.start(1, TimeUnit.MINUTES); }
Example 2
Source File: MetricsConfiguration.java From expper with GNU General Public License v3.0 | 6 votes |
@PostConstruct private void init() { if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 3
Source File: MetricsConfiguration.java From ServiceCutter with Apache License 2.0 | 6 votes |
@PostConstruct private void init() { Boolean graphiteEnabled = propertyResolver.getProperty(PROP_GRAPHITE_ENABLED, Boolean.class, false); if (graphiteEnabled) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = propertyResolver.getRequiredProperty(PROP_HOST); Integer graphitePort = propertyResolver.getRequiredProperty(PROP_PORT, Integer.class); String graphitePrefix = propertyResolver.getProperty(PROP_GRAPHITE_PREFIX, String.class, ""); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 4
Source File: MetricsConfiguration.java From angularjs-springboot-bookstore with MIT License | 6 votes |
@PostConstruct private void init() { Boolean graphiteEnabled = propertyResolver.getProperty(PROP_GRAPHITE_ENABLED, Boolean.class, false); if (graphiteEnabled) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = propertyResolver.getRequiredProperty(PROP_HOST); Integer graphitePort = propertyResolver.getRequiredProperty(PROP_PORT, Integer.class); String graphitePrefix = propertyResolver.getProperty(PROP_GRAPHITE_PREFIX, String.class, ""); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 5
Source File: MetricsReporters.java From StubbornJava with MIT License | 6 votes |
public static void startReporters(MetricRegistry registry) { // Graphite reporter to Grafana Cloud OkHttpClient client = new OkHttpClient.Builder() //.addNetworkInterceptor(HttpClient.getLoggingInterceptor()) .build(); if (!Configs.properties().hasPath("metrics.graphite.host") || !Configs.properties().hasPath("metrics.grafana.api_key")) { log.info("Missing metrics reporter key or host skipping"); return; } String graphiteHost = Configs.properties().getString("metrics.graphite.host"); String grafanaApiKey = Configs.properties().getString("metrics.grafana.api_key"); final GraphiteHttpSender graphite = new GraphiteHttpSender(client, graphiteHost, grafanaApiKey); final GraphiteReporter reporter = GraphiteReporter.forRegistry(registry) .prefixedWith(Metrics.metricPrefix("stubbornjava")) .convertRatesTo(TimeUnit.MINUTES) .convertDurationsTo(TimeUnit.MILLISECONDS) .filter(MetricFilter.ALL) .build(graphite); reporter.start(10, TimeUnit.SECONDS); }
Example 6
Source File: MetricsConfiguration.java From OpenIoE with Apache License 2.0 | 6 votes |
@PostConstruct private void init() { if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 7
Source File: MetricsConfiguration.java From gpmr with Apache License 2.0 | 6 votes |
@PostConstruct private void init() { if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 8
Source File: DropwizardHelper.java From okapi with Apache License 2.0 | 6 votes |
/** * Configure Dropwizard helper. * @param graphiteHost graphite server host * @param port graphits server port * @param tu time unit * @param period reporting period * @param vopt Vert.x options * @param hostName logical hostname for this node (reporting) */ public static void config(String graphiteHost, int port, TimeUnit tu, int period, VertxOptions vopt, String hostName) { final String registryName = "okapi"; MetricRegistry registry = SharedMetricRegistries.getOrCreate(registryName); DropwizardMetricsOptions metricsOpt = new DropwizardMetricsOptions(); metricsOpt.setEnabled(true).setRegistryName(registryName); vopt.setMetricsOptions(metricsOpt); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, port)); final String prefix = "folio.okapi." + hostName; GraphiteReporter reporter = GraphiteReporter.forRegistry(registry) .prefixedWith(prefix) .build(graphite); reporter.start(period, tu); logger.info("Metrics remote {}:{} this {}", graphiteHost, port, prefix); }
Example 9
Source File: MetricsConfiguration.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 6 votes |
@PostConstruct private void init() { if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 10
Source File: _MetricsConfiguration.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 6 votes |
@PostConstruct private void init() { if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 11
Source File: MetricsConfiguration.java From jhipster-ribbon-hystrix with GNU General Public License v3.0 | 6 votes |
@PostConstruct private void init() { if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 12
Source File: GraphiteReporterStarter.java From fluo with Apache License 2.0 | 6 votes |
@Override public List<AutoCloseable> start(Params params) { SimpleConfiguration config = new FluoConfiguration(params.getConfiguration()).getReporterConfiguration("graphite"); if (!config.getBoolean("enable", false)) { return Collections.emptyList(); } String host = config.getString("host"); String prefix = config.getString("prefix", ""); int port = config.getInt("port", 8080); TimeUnit rateUnit = TimeUnit.valueOf(config.getString("rateUnit", "seconds").toUpperCase()); TimeUnit durationUnit = TimeUnit.valueOf(config.getString("durationUnit", "milliseconds").toUpperCase()); Graphite graphite = new Graphite(host, port); GraphiteReporter reporter = GraphiteReporter.forRegistry(params.getMetricRegistry()).convertDurationsTo(durationUnit) .convertRatesTo(rateUnit).prefixedWith(prefix).build(graphite); reporter.start(config.getInt("frequency", 60), TimeUnit.SECONDS); log.info("Reporting metrics to graphite server {}:{}", host, port); return Collections.singletonList((AutoCloseable) reporter); }
Example 13
Source File: MetricsReporters.java From StubbornJava with MIT License | 6 votes |
public static void startReporters(MetricRegistry registry) { // Graphite reporter to Grafana Cloud OkHttpClient client = new OkHttpClient.Builder() //.addNetworkInterceptor(HttpClient.getLoggingInterceptor()) .build(); if (!Configs.properties().hasPath("metrics.graphite.host") || !Configs.properties().hasPath("metrics.grafana.api_key")) { log.info("Missing metrics reporter key or host skipping"); return; } String graphiteHost = Configs.properties().getString("metrics.graphite.host"); String grafanaApiKey = Configs.properties().getString("metrics.grafana.api_key"); final GraphiteHttpSender graphite = new GraphiteHttpSender(client, graphiteHost, grafanaApiKey); final GraphiteReporter reporter = GraphiteReporter.forRegistry(registry) .prefixedWith(Metrics.metricPrefix("stubbornjava")) .convertRatesTo(TimeUnit.MINUTES) .convertDurationsTo(TimeUnit.MILLISECONDS) .filter(MetricFilter.ALL) .build(graphite); reporter.start(10, TimeUnit.SECONDS); }
Example 14
Source File: MetricsConfiguration.java From klask-io with GNU General Public License v3.0 | 6 votes |
@PostConstruct private void init() { if (jHipsterProperties.getMetrics().getGraphite().isEnabled()) { log.info("Initializing Metrics Graphite reporting"); String graphiteHost = jHipsterProperties.getMetrics().getGraphite().getHost(); Integer graphitePort = jHipsterProperties.getMetrics().getGraphite().getPort(); String graphitePrefix = jHipsterProperties.getMetrics().getGraphite().getPrefix(); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .prefixedWith(graphitePrefix) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 15
Source File: MetricsManager.java From emissary with Apache License 2.0 | 6 votes |
protected void initGraphiteReporter() { if (!this.conf.findBooleanEntry("GRAPHITE_METRICS_ENABLED", false)) { logger.debug("Graphite Metrics are disabled"); return; } logger.debug("Graphite Metrics are enabled"); final String prefix = this.conf.findStringEntry("GRAPHITE_METRICS_PREFIX", "emissary"); final String host = this.conf.findStringEntry("GRAPHITE_METRICS_HOST", "localhost"); final int port = this.conf.findIntEntry("GRAPHITE_METRICS_PORT", 2003); final int interval = this.conf.findIntEntry("GRAPHITE_METRICS_INTERVAL", -1); final TimeUnit intervalUnit = TimeUnit.valueOf(this.conf.findStringEntry("GRAPHITE_METRICS_INTERVAL_UNIT", TimeUnit.MINUTES.name())); final TimeUnit rateUnit = TimeUnit.valueOf(this.conf.findStringEntry("GRAPHITE_RATE_UNIT", TimeUnit.SECONDS.name())); final TimeUnit durationUnit = TimeUnit.valueOf(this.conf.findStringEntry("GRAPHITE_DURATION_UNIT", TimeUnit.MILLISECONDS.name())); final Graphite graphite = new Graphite(new InetSocketAddress(host, port)); final GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(this.metrics).prefixedWith(prefix).convertRatesTo(rateUnit).convertDurationsTo(durationUnit) .filter(MetricFilter.ALL).build(graphite); if (interval > 0) { graphiteReporter.start(interval, intervalUnit); } }
Example 16
Source File: MetricsConfiguration.java From find with MIT License | 5 votes |
@Bean @ConditionalOnProperty(GRAPHITE_HOST_PROPERTY_KEY) public GraphiteReporter graphiteReporter(final MetricRegistry registry, @Value(GRAPHITE_HOST_PROPERTY) final String graphiteHost, @Value(GRAPHITE_PORT_PROPERTY) final int graphitePort, @Value(GRAPHITE_SCHEDULE_INTERVAL_PROPERTY) final int graphiteScheduleInterval) { final Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); final GraphiteReporter reporter = GraphiteReporter.forRegistry(registry) .prefixedWith(GRAPHITE_PREFIX) .build(graphite); reporter.start(graphiteScheduleInterval, TimeUnit.MILLISECONDS); return reporter; }
Example 17
Source File: GraphiteMetricsReporter.java From user-registration-V2 with Apache License 2.0 | 5 votes |
@PostConstruct private void init() { if (graphiteEnabled) { log.info("Initializing Metrics Graphite reporting"); Graphite graphite = new Graphite(new InetSocketAddress( graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter .forRegistry(metricRegistry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS).build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } }
Example 18
Source File: Main.java From RestExpress-Examples with Apache License 2.0 | 5 votes |
private static void configureMetrics(Configuration config, RestExpress server) { MetricsConfig mc = config.getMetricsConfig(); if (mc.isEnabled()) { MetricRegistry registry = new MetricRegistry(); new MetricsPlugin(registry) .register(server); if (mc.isGraphiteEnabled()) { final Graphite graphite = new Graphite(new InetSocketAddress(mc.getGraphiteHost(), mc.getGraphitePort())); final GraphiteReporter reporter = GraphiteReporter.forRegistry(registry) .prefixedWith(mc.getPrefix()) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .filter(MetricFilter.ALL) .build(graphite); reporter.start(mc.getPublishSeconds(), TimeUnit.SECONDS); } else { LOG.warn("*** Graphite Metrics Publishing is Disabled ***"); } } else { LOG.warn("*** Metrics Generation is Disabled ***"); } }
Example 19
Source File: CommaFeedModule.java From commafeed with Apache License 2.0 | 4 votes |
@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."); } }
Example 20
Source File: DashboardExtension.java From wisdom with Apache License 2.0 | 4 votes |
/** * Starts the dashboard. */ @Validate public void start() { logger().info("Registering JVM metrics"); registry.register("jvm.memory", new MemoryUsageGaugeSet()); registry.register("jvm.garbage", new GarbageCollectorMetricSet()); registry.register("jvm.threads", new ThreadStatesGaugeSet()); registry.register("jvm.buffers", new BufferPoolMetricSet(ManagementFactory.getPlatformMBeanServer())); registry.register("jvm.cpu", new CpuGaugeSet()); registry.register("jvm.runtime", new RuntimeGaugeSet()); if (configuration.getBooleanWithDefault("monitor.http.enabled", true)) { logger().info("Registering HTTP metrics"); this.httpMetricFilter = new HttpMetricFilter(bc, configuration, registry); httpMetricFilter.start(); } if (configuration.getBooleanWithDefault("monitor.jmx.enabled", true)) { logger().info("Initializing Metrics JMX reporting"); final JmxReporter jmxReporter = JmxReporter.forRegistry(registry).build(); jmxReporter.start(); } if (configuration.getBooleanWithDefault("monitor.graphite.enabled", false)) { logger().info("Initializing Metrics Graphite reporting"); String graphiteHost = configuration.getOrDie("monitor.graphite.host"); int graphitePort = configuration.getIntegerOrDie("monitor.graphite.port"); Graphite graphite = new Graphite(new InetSocketAddress(graphiteHost, graphitePort)); GraphiteReporter graphiteReporter = GraphiteReporter.forRegistry(registry) .convertRatesTo(TimeUnit.SECONDS) .convertDurationsTo(TimeUnit.MILLISECONDS) .build(graphite); graphiteReporter.start(1, TimeUnit.MINUTES); } logger().info("Registering the metric registry as service"); reg = bc.registerService(MetricRegistry.class, registry, null); task = scheduler.scheduleAtFixedRate(new Runnable() { /** * Sends updated data to the websocket. */ public void run() { publisher.publish("/monitor/update", json.toJson(getData())); } }, 0, 10, TimeUnit.SECONDS); }