Search in sources :

Example 51 with Properties

use of loghub.configuration.Properties in project LogHub by fbacchella.

the class TestGrok method TestLoadPatterns2.

@Test
public void TestLoadPatterns2() throws ProcessorException {
    Grok grok = new Grok();
    grok.setField("message");
    grok.setPattern("(?:%{SYSLOG_LINE})");
    Properties props = new Properties(Collections.emptyMap());
    Assert.assertTrue("Failed to configure grok", grok.configure(props));
    Event e = Tools.getEvent();
    e.put("message", "<34>1 2016-01-25T12:28:00.164593+01:00 somehost krb5kdc 4906 - -  closing down fd 14");
    e.process(grok);
    Assert.assertEquals("invalid syslog line matching", 8, e.size());
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 52 with Properties

use of loghub.configuration.Properties in project LogHub by fbacchella.

the class TestGrok method TestLoadPatterns3.

@Test
public void TestLoadPatterns3() throws ProcessorException {
    Grok grok = new Grok();
    grok.setField("message");
    grok.setCustomPatterns(Collections.singletonMap("FETCHING", "fetching user_deny.db entry"));
    grok.setPattern("%{FETCHING:message} for '%{USERNAME:imap_user}'");
    Properties props = new Properties(Collections.emptyMap());
    Assert.assertTrue("Failed to configure grok", grok.configure(props));
    Event e = Tools.getEvent();
    e.put("message", "fetching user_deny.db entry for 'someone'");
    e.process(grok);
    Assert.assertEquals("invalid syslog line matching", 2, e.size());
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 53 with Properties

use of loghub.configuration.Properties in project LogHub by fbacchella.

the class TestGrok method TestLoadPatterns1.

@Test
public void TestLoadPatterns1() throws ProcessorException {
    Grok grok = new Grok();
    grok.setField("message");
    grok.setPattern("%{COMBINEDAPACHELOG}");
    Properties props = new Properties(Collections.emptyMap());
    Assert.assertTrue("Failed to configure grok", grok.configure(props));
    Event e = Tools.getEvent();
    e.put("message", "112.169.19.192 - - [06/Mar/2013:01:36:30 +0900] \"GET / HTTP/1.1\" 200 44346 \"-\" \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.152 Safari/537.22\"");
    e.process(grok);
    Assert.assertEquals("Didn't find the good user agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.152 Safari/537.22", e.get("agent"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Test(org.junit.Test)

Example 54 with Properties

use of loghub.configuration.Properties in project LogHub by fbacchella.

the class TestMapper method test4.

@Test
public void test4() throws ProcessorException, InterruptedException, ConfigException, IOException {
    Properties conf = Tools.loadConf("map.conf");
    for (Pipeline pipe : conf.pipelines) {
        Assert.assertTrue("configuration failed", pipe.configure(conf));
    }
    Event sent = Tools.getEvent();
    sent.put("a", 2L);
    Tools.runProcessing(sent, conf.namedPipeLine.get("mapper2"), conf);
    Assert.assertEquals("conversion not expected", "c", sent.get("a"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Pipeline(loghub.Pipeline) Test(org.junit.Test)

Example 55 with Properties

use of loghub.configuration.Properties in project LogHub by fbacchella.

the class TestMapper method test1.

@Test
public void test1() throws ProcessorException, InterruptedException, ConfigException, IOException {
    Properties conf = Tools.loadConf("map.conf");
    for (Pipeline pipe : conf.pipelines) {
        Assert.assertTrue("configuration failed", pipe.configure(conf));
    }
    Event sent = Tools.getEvent();
    sent.put("a", 1);
    Tools.runProcessing(sent, conf.namedPipeLine.get("mapper1"), conf);
    Assert.assertEquals("conversion not expected", "b", sent.get("d"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Pipeline(loghub.Pipeline) Test(org.junit.Test)

Aggregations

Properties (loghub.configuration.Properties)74 Test (org.junit.Test)65 Event (loghub.Event)64 Pipeline (loghub.Pipeline)23 Date (java.util.Date)17 Map (java.util.Map)13 IOException (java.io.IOException)12 HashMap (java.util.HashMap)10 Collections (java.util.Collections)7 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)7 Level (org.apache.logging.log4j.Level)7 LogManager (org.apache.logging.log4j.LogManager)7 Logger (org.apache.logging.log4j.Logger)7 LogUtils (loghub.LogUtils)6 ProcessorException (loghub.ProcessorException)6 Tools (loghub.Tools)6 Assert (org.junit.Assert)6 BeforeClass (org.junit.BeforeClass)6 ConfigException (loghub.configuration.ConfigException)5 StringReader (java.io.StringReader)4