Search in sources :

Example 1 with LogsIngestionConfig

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()))));
}
Also used : LogsIngestionConfig(com.wavefront.agent.config.LogsIngestionConfig) Test(org.junit.Test)

Example 2 with LogsIngestionConfig

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();
    }
}
Also used : MetricMatcher(com.wavefront.agent.config.MetricMatcher) LogsIngestionConfig(com.wavefront.agent.config.LogsIngestionConfig)

Example 3 with LogsIngestionConfig

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);
}
Also used : RawLogsIngesterPortUnificationHandler(com.wavefront.agent.listeners.RawLogsIngesterPortUnificationHandler) ReportableEntityHandler(com.wavefront.agent.handlers.ReportableEntityHandler) EasyMock.reset(org.easymock.EasyMock.reset) Map(java.util.Map) After(org.junit.After) HandlerKey(com.wavefront.agent.handlers.HandlerKey) ReportPoint(wavefront.report.ReportPoint) GrokException(oi.thekraken.grok.api.exception.GrokException) LogsIngestionConfig(com.wavefront.agent.config.LogsIngestionConfig) ImmutableMap(com.google.common.collect.ImmutableMap) InetSocketAddress(java.net.InetSocketAddress) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ReportableEntityType(com.wavefront.data.ReportableEntityType) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) PointMatchers(com.wavefront.agent.PointMatchers) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MetricMatcher(com.wavefront.agent.config.MetricMatcher) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) RawLogsIngesterPortUnificationHandler(com.wavefront.agent.listeners.RawLogsIngesterPortUnificationHandler) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) Matchers.lessThan(org.hamcrest.Matchers.lessThan) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ConfigurationException(com.wavefront.agent.config.ConfigurationException) EasyMock.replay(org.easymock.EasyMock.replay) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) EasyMock.createMock(org.easymock.EasyMock.createMock) TokenAuthenticatorBuilder(com.wavefront.agent.auth.TokenAuthenticatorBuilder) MetricConstants(com.wavefront.common.MetricConstants) Capture(org.easymock.Capture) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) EasyMock.expect(org.easymock.EasyMock.expect) Maps(com.google.common.collect.Maps) File(java.io.File) Message(org.logstash.beats.Message) Consumer(java.util.function.Consumer) Channel(io.netty.channel.Channel) EasyMock.expectLastCall(org.easymock.EasyMock.expectLastCall) AtomicLong(java.util.concurrent.atomic.AtomicLong) Matchers.emptyIterable(org.hamcrest.Matchers.emptyIterable) CaptureType(org.easymock.CaptureType) ReportableEntityHandlerFactory(com.wavefront.agent.handlers.ReportableEntityHandlerFactory) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) EasyMock.verify(org.easymock.EasyMock.verify) Histogram(wavefront.report.Histogram) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) ReportableEntityHandler(com.wavefront.agent.handlers.ReportableEntityHandler) ReportableEntityHandlerFactory(com.wavefront.agent.handlers.ReportableEntityHandlerFactory)

Example 4 with LogsIngestionConfig

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());
}
Also used : ReportableEntityHandler(com.wavefront.agent.handlers.ReportableEntityHandler) EasyMock.reset(org.easymock.EasyMock.reset) Map(java.util.Map) After(org.junit.After) HandlerKey(com.wavefront.agent.handlers.HandlerKey) ReportPoint(wavefront.report.ReportPoint) GrokException(oi.thekraken.grok.api.exception.GrokException) LogsIngestionConfig(com.wavefront.agent.config.LogsIngestionConfig) ImmutableMap(com.google.common.collect.ImmutableMap) InetSocketAddress(java.net.InetSocketAddress) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ReportableEntityType(com.wavefront.data.ReportableEntityType) List(java.util.List) Matchers.contains(org.hamcrest.Matchers.contains) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Matchers.equalTo(org.hamcrest.Matchers.equalTo) PointMatchers(com.wavefront.agent.PointMatchers) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MetricMatcher(com.wavefront.agent.config.MetricMatcher) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) RawLogsIngesterPortUnificationHandler(com.wavefront.agent.listeners.RawLogsIngesterPortUnificationHandler) YAMLFactory(com.fasterxml.jackson.dataformat.yaml.YAMLFactory) Matchers.lessThan(org.hamcrest.Matchers.lessThan) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ConfigurationException(com.wavefront.agent.config.ConfigurationException) EasyMock.replay(org.easymock.EasyMock.replay) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) EasyMock.createMock(org.easymock.EasyMock.createMock) TokenAuthenticatorBuilder(com.wavefront.agent.auth.TokenAuthenticatorBuilder) MetricConstants(com.wavefront.common.MetricConstants) Capture(org.easymock.Capture) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) Test(org.junit.Test) EasyMock(org.easymock.EasyMock) EasyMock.expect(org.easymock.EasyMock.expect) Maps(com.google.common.collect.Maps) File(java.io.File) Message(org.logstash.beats.Message) Consumer(java.util.function.Consumer) Channel(io.netty.channel.Channel) EasyMock.expectLastCall(org.easymock.EasyMock.expectLastCall) AtomicLong(java.util.concurrent.atomic.AtomicLong) Matchers.emptyIterable(org.hamcrest.Matchers.emptyIterable) CaptureType(org.easymock.CaptureType) ReportableEntityHandlerFactory(com.wavefront.agent.handlers.ReportableEntityHandlerFactory) NoopHealthCheckManager(com.wavefront.agent.channel.NoopHealthCheckManager) EasyMock.verify(org.easymock.EasyMock.verify) Histogram(wavefront.report.Histogram) MetricMatcher(com.wavefront.agent.config.MetricMatcher) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Aggregations

LogsIngestionConfig (com.wavefront.agent.config.LogsIngestionConfig)4 MetricMatcher (com.wavefront.agent.config.MetricMatcher)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)2 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 Lists (com.google.common.collect.Lists)2 Maps (com.google.common.collect.Maps)2 PointMatchers (com.wavefront.agent.PointMatchers)2 TokenAuthenticatorBuilder (com.wavefront.agent.auth.TokenAuthenticatorBuilder)2 NoopHealthCheckManager (com.wavefront.agent.channel.NoopHealthCheckManager)2 ConfigurationException (com.wavefront.agent.config.ConfigurationException)2 HandlerKey (com.wavefront.agent.handlers.HandlerKey)2 ReportableEntityHandler (com.wavefront.agent.handlers.ReportableEntityHandler)2 ReportableEntityHandlerFactory (com.wavefront.agent.handlers.ReportableEntityHandlerFactory)2 RawLogsIngesterPortUnificationHandler (com.wavefront.agent.listeners.RawLogsIngesterPortUnificationHandler)2 MetricConstants (com.wavefront.common.MetricConstants)2 ReportableEntityType (com.wavefront.data.ReportableEntityType)2 Channel (io.netty.channel.Channel)2 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)2