private String getGraphitePrefix(MeasurementSession measurementSession) { return name( "stagemonitor", sanitizeGraphiteMetricSegment(measurementSession.getApplicationName()), sanitizeGraphiteMetricSegment(measurementSession.getInstanceName()), sanitizeGraphiteMetricSegment(measurementSession.getHostName())); }
private void reportToInfluxDb( Metric2Registry metricRegistry, int reportingInterval, MeasurementSession measurementSession) { if (StringUtils.isNotEmpty(getInfluxDbUrl()) && reportingInterval > 0) { logger.info( "Sending metrics to InfluxDB ({}) every {}s", getInfluxDbUrl(), reportingInterval); final InfluxDbReporter reporter = new InfluxDbReporter( metricRegistry, Metric2Filter.ALL, TimeUnit.SECONDS, TimeUnit.MILLISECONDS, measurementSession.asMap(), new HttpClient(), this); reporter.start(reportingInterval, TimeUnit.SECONDS); reporters.add(reporter); } else { logger.info( "Not sending metrics to InfluxDB (url={}, interval={}s)", getInfluxDbUrl(), reportingInterval); } }
private void reportToElasticsearch( Metric2Registry metricRegistry, int reportingInterval, final MeasurementSession measurementSession, CorePlugin corePlugin) { if (isReportToElasticsearch()) { elasticsearchClient.sendBulkAsync("KibanaConfig.bulk"); logger.info( "Sending metrics to Elasticsearch ({}) every {}s", getElasticsearchUrl(), reportingInterval); final String mappingJson = ElasticsearchClient.requireBoxTypeHotIfHotColdAritectureActive( "stagemonitor-elasticsearch-metrics-index-template.json", corePlugin.moveToColdNodesAfterDays.getValue()); elasticsearchClient.sendMappingTemplateAsync(mappingJson, "stagemonitor-metrics"); final ElasticsearchReporter reporter = new ElasticsearchReporter( metricRegistry, Metric2Filter.ALL, TimeUnit.SECONDS, TimeUnit.MILLISECONDS, measurementSession.asMap(), new HttpClient(), this); reporter.start(reportingInterval, TimeUnit.SECONDS); reporters.add(reporter); elasticsearchClient.scheduleIndexManagement( ElasticsearchReporter.STAGEMONITOR_METRICS_INDEX_PREFIX, moveToColdNodesAfterDays.getValue(), deleteElasticsearchMetricsAfterDays.getValue()); } else { logger.info( "Not sending metrics to Elasticsearch (url={}, interval={}s)", getElasticsearchUrl(), reportingInterval); } }