Search in sources :

Example 71 with Event

use of loghub.Event 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 72 with Event

use of loghub.Event 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 73 with Event

use of loghub.Event 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 74 with Event

use of loghub.Event 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)

Example 75 with Event

use of loghub.Event in project LogHub by fbacchella.

the class TestMapper method test2.

@Test
public void test2() 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("mapper2"), conf);
    Assert.assertEquals("conversion not expected", "b", sent.get("a"));
}
Also used : Event(loghub.Event) Properties(loghub.configuration.Properties) Pipeline(loghub.Pipeline) Test(org.junit.Test)

Aggregations

Event (loghub.Event)102 Test (org.junit.Test)90 Properties (loghub.configuration.Properties)63 Pipeline (loghub.Pipeline)23 Date (java.util.Date)19 Map (java.util.Map)18 HashMap (java.util.HashMap)14 IOException (java.io.IOException)13 Tools (loghub.Tools)13 URL (java.net.URL)8 Collections (java.util.Collections)8 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)8 Level (org.apache.logging.log4j.Level)7 List (java.util.List)6 EventsProcessor (loghub.EventsProcessor)6 LogManager (org.apache.logging.log4j.LogManager)6 Logger (org.apache.logging.log4j.Logger)6 LogUtils (loghub.LogUtils)5 ProcessorException (loghub.ProcessorException)5 Assert (org.junit.Assert)5