private void registerReporters(Metric2Registry metric2Registry, Configuration configuration) { RegexMetricFilter regexFilter = new RegexMetricFilter(getExcludedMetricsPatterns()); MetricFilter allFilters = new OrMetricFilter(regexFilter, new MetricsWithCountFilter()); MetricRegistry metricRegistry = metric2Registry.getMetricRegistry(); reportToGraphite( metricRegistry, getGraphiteReportingInterval(), Stagemonitor.getMeasurementSession(), allFilters); reportToInfluxDb( metric2Registry, reportingIntervalInfluxDb.getValue(), Stagemonitor.getMeasurementSession()); reportToElasticsearch( metric2Registry, reportingIntervalElasticsearch.getValue(), Stagemonitor.getMeasurementSession(), configuration.getConfig(CorePlugin.class)); List<ScheduledReporter> onShutdownReporters = new LinkedList<ScheduledReporter>(); onShutdownReporters.add( new SimpleElasticsearchReporter( getElasticsearchClient(), metricRegistry, "simple-es-reporter", allFilters)); reportToConsole(metricRegistry, getConsoleReportingInterval(), allFilters, onShutdownReporters); registerAggregationReporter( metricRegistry, allFilters, onShutdownReporters, getAggregationReportingInterval()); if (reportToJMX()) { reportToJMX(metricRegistry, allFilters); } }
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); } }
public boolean isCollectSql() { return collectSql.getValue(); }
public boolean isMonitorOnlySpringMvcRequests() { return monitorOnlySpringMvcOption.getValue(); }
public String getMetricsServletAllowedOrigin() { return metricsServletAllowedOrigin.getValue(); }
public boolean isCollectPageLoadTimesPerRequest() { return collectPageLoadTimesPerRequest.getValue(); }
public boolean isWidgetEnabled() { return widgetEnabled.getValue(); }
public boolean isCollectHttpHeaders() { return collectHttpHeaders.getValue(); }
public Integer getReloadConfigurationInterval() { return reloadConfigurationInterval.getValue(); }
public boolean isDeactivateStagemonitorIfEsConfigSourceIsDown() { return deactivateStagemonitorIfEsConfigSourceIsDown.getValue(); }
public String getElasticsearchUrl() { return removeTrailingSlash(elasticsearchUrl.getValue()); }
public String getInstanceName() { return instanceName.getValue(); }
public String getApplicationName() { return applicationName.getValue(); }
public int getGraphitePort() { return graphitePort.getValue(); }
public String getGraphiteHostName() { return graphiteHostName.getValue(); }
public int getElasticsearchReportingInterval() { return reportingIntervalElasticsearch.getValue(); }
public Integer getMoveToColdNodesAfterDays() { return moveToColdNodesAfterDays.getValue(); }
public boolean isAttachAgentAtRuntime() { return attachAgentAtRuntime.getValue(); }
public boolean isParseUserAgent() { return parseUserAgent.getValue(); }
public String getInfluxDbUrl() { return removeTrailingSlash(influxDbUrl.getValue()); }
public boolean isRealUserMonitoringEnabled() { return rumEnabled.getValue(); }
public String getInfluxDbDb() { return influxDbDb.getValue(); }
public boolean isMonitorOnlyForwardedRequests() { return monitorOnlyForwardedRequests.getValue(); }
public boolean isReportToElasticsearch() { return StringUtils.isNotEmpty(getElasticsearchUrl()) && reportingIntervalElasticsearch.getValue() > 0; }
public String getMetricsServletJsonpParamName() { return metricsServletJsonpParameter.getValue(); }
public String getGrafanaUrl() { return removeTrailingSlash(grafanaUrl.getValue()); }
public boolean isMonitorOnlyResteasyRequests() { return monitorOnlyResteasyOption.getValue(); }
public String getGrafanaApiKey() { return grafanaApiKey.getValue(); }
public boolean isCollectPreparedStatementParameters() { return collectPreparedStatementParameters.getValue(); }
public int getThreadPoolQueueCapacityLimit() { return threadPoolQueueCapacityLimit.getValue(); }