use of com.wavefront.agent.config.LogsIngestionConfig in project java by wavefrontHQ.
the class LogsIngesterTest method testMetricsAggregationNonDeltaCounters.
@Test
public void testMetricsAggregationNonDeltaCounters() throws Exception {
LogsIngestionConfig config = parseConfigFile("test.yml");
config.useDeltaCounters = false;
setup(config);
assertThat(getPoints(6, "plainCounter", "noMatch 42.123 bar", "plainCounter", "gauges 42", "counterWithValue 2", "counterWithValue 3", "dynamicCounter foo 1 done", "dynamicCounter foo 2 done", "dynamicCounter baz 1 done"), containsInAnyOrder(ImmutableList.of(PointMatchers.matches(2L, "plainCounter", ImmutableMap.of()), PointMatchers.matches(5L, "counterWithValue", ImmutableMap.of()), PointMatchers.matches(1L, "dynamic_foo_1", ImmutableMap.of()), PointMatchers.matches(1L, "dynamic_foo_2", ImmutableMap.of()), PointMatchers.matches(1L, "dynamic_baz_1", ImmutableMap.of()), PointMatchers.matches(42.0, "myGauge", ImmutableMap.of()))));
}
use of com.wavefront.agent.config.LogsIngestionConfig in project java by wavefrontHQ.
the class LogsIngester method ingestLog.
public void ingestLog(LogsMessage logsMessage) {
LogsIngestionConfig logsIngestionConfig = logsIngestionConfigManager.getConfig();
boolean success = false;
for (MetricMatcher metricMatcher : logsIngestionConfig.counters) {
success |= maybeIngestLog(evictingMetricsRegistry::getCounter, metricMatcher, logsMessage);
}
for (MetricMatcher metricMatcher : logsIngestionConfig.gauges) {
success |= maybeIngestLog(evictingMetricsRegistry::getGauge, metricMatcher, logsMessage);
}
for (MetricMatcher metricMatcher : logsIngestionConfig.histograms) {
success |= maybeIngestLog(evictingMetricsRegistry::getHistogram, metricMatcher, logsMessage);
}
if (success) {
parsed.inc();
} else {
unparsed.inc();
}
}
use of com.wavefront.agent.config.LogsIngestionConfig in project java by wavefrontHQ.
the class LogsIngesterTest method setup.
private void setup(LogsIngestionConfig config) throws IOException, GrokException, ConfigurationException {
logsIngestionConfig = config;
// HACK: Never call flush automatically.
logsIngestionConfig.aggregationIntervalSeconds = 10000;
logsIngestionConfig.verifyAndInit();
mockPointHandler = createMock(ReportableEntityHandler.class);
mockHistogramHandler = createMock(ReportableEntityHandler.class);
mockFactory = createMock(ReportableEntityHandlerFactory.class);
expect((ReportableEntityHandler) mockFactory.getHandler(HandlerKey.of(ReportableEntityType.POINT, "logs-ingester"))).andReturn(mockPointHandler).anyTimes();
expect((ReportableEntityHandler) mockFactory.getHandler(HandlerKey.of(ReportableEntityType.HISTOGRAM, "logs-ingester"))).andReturn(mockHistogramHandler).anyTimes();
replay(mockFactory);
logsIngesterUnderTest = new LogsIngester(mockFactory, () -> logsIngestionConfig, null, now::get, nanos::get);
logsIngesterUnderTest.start();
filebeatIngesterUnderTest = new FilebeatIngester(logsIngesterUnderTest, now::get);
rawLogsIngesterUnderTest = new RawLogsIngesterPortUnificationHandler("12345", logsIngesterUnderTest, x -> "testHost", TokenAuthenticatorBuilder.create().build(), new NoopHealthCheckManager(), null);
}
use of com.wavefront.agent.config.LogsIngestionConfig in project java by wavefrontHQ.
the class LogsIngesterTest method testHotloadedConfigClearsOldMetrics.
@Test
public void testHotloadedConfigClearsOldMetrics() throws Exception {
setup(parseConfigFile("test.yml"));
assertThat(getPoints(1, "plainCounter"), contains(PointMatchers.matches(1L, MetricConstants.DELTA_PREFIX + "plainCounter", ImmutableMap.of())));
// once the counter is reported, it is reset because now it is treated as delta counter.
// hence we check that plainCounter has value 1L below.
assertThat(getPoints(2, "plainCounter", "counterWithValue 42"), containsInAnyOrder(ImmutableList.of(PointMatchers.matches(42L, MetricConstants.DELTA_PREFIX + "counterWithValue", ImmutableMap.of()), PointMatchers.matches(1L, MetricConstants.DELTA_PREFIX + "plainCounter", ImmutableMap.of()))));
List<MetricMatcher> counters = Lists.newCopyOnWriteArrayList(logsIngestionConfig.counters);
int oldSize = counters.size();
counters.removeIf((metricMatcher -> metricMatcher.getPattern().equals("plainCounter")));
assertThat(counters, hasSize(oldSize - 1));
// Get a new config file because the SUT has a reference to the old one, and we'll be monkey patching
// this one.
logsIngestionConfig = parseConfigFile("test.yml");
logsIngestionConfig.verifyAndInit();
logsIngestionConfig.counters = counters;
logsIngesterUnderTest.logsIngestionConfigManager.forceConfigReload();
// once the counter is reported, it is reset because now it is treated as delta counter.
// since zero values are filtered out, no new values are expected.
assertThat(getPoints(0, "plainCounter"), emptyIterable());
}
Aggregations