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());
}
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());
}
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"));
}
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"));
}
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"));
}
Aggregations