use of loghub.Event in project LogHub by fbacchella.
the class TestEtl method test6.
@Test
public void test6() throws ProcessorException, InterruptedException, ConfigException, IOException {
Properties conf = Tools.loadConf("etl.conf");
for (Pipeline pipe : conf.pipelines) {
Assert.assertTrue("configuration failed", pipe.configure(conf));
}
Event sent = Tools.getEvent();
sent.put("count", "1");
Tools.runProcessing(sent, conf.namedPipeLine.get("second"), conf);
Assert.assertEquals("conversion not expected", 1, sent.get("count"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestFieldsProcessor method test.
@Test
public void test() throws ProcessorException {
FieldsProcessor p = new FieldsProcessor() {
@Override
public boolean processMessage(Event event, String field, String destination) throws ProcessorException {
event.put(destination, event.get(field));
return true;
}
@Override
public String getName() {
return null;
}
};
p.setDestination("${field}_done");
p.setFields(new String[] { "a", "b" });
Event e = Tools.getEvent();
e.put("a", 1);
e.put("b", 2);
Tools.runProcessing(e, "main", Collections.singletonList(p));
Assert.assertEquals("destination field wrong", 1, e.get("a_done"));
Assert.assertEquals("destination field wrong", 2, e.get("b_done"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestGrok method TestLoadPatterns6.
@Test
public void TestLoadPatterns6() throws ProcessorException {
Grok grok = new Grok();
grok.setFields(new String[] { "remotehost" });
grok.setPattern("%{HOSTNAME:.}\\.google\\.com");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("localhost", "127.0.0.1");
e.put("remotehost", "www.google.com");
e.put("remotehostother", "www.google.com");
e.put("host", "www.yahoo.com");
Tools.runProcessing(e, "main", Collections.singletonList(grok));
Assert.assertEquals("invalid FQDN matching", "www", e.get("remotehost"));
}
use of loghub.Event in project LogHub by fbacchella.
the class TestGrok method TestLoadPatterns5.
@Test
public void TestLoadPatterns5() throws ProcessorException {
Grok grok = new Grok();
grok.setFields(new String[] { "localhost" });
grok.setPattern("%{HOSTNAME:.}\\.google\\.com");
Properties props = new Properties(Collections.emptyMap());
Assert.assertTrue("Failed to configure grok", grok.configure(props));
Event e = Tools.getEvent();
e.put("localhost", "127.0.0.1");
e.put("remotehost", "www.google.com");
e.put("remotehostother", "www.google.com");
e.put("host", "www.yahoo.com");
Tools.runProcessing(e, "main", Collections.singletonList(grok));
Assert.assertEquals("invalid FQDN matching", "www.google.com", e.get("remotehost"));
Assert.assertEquals("invalid FQDN matching", "127.0.0.1", e.get("localhost"));
}
use of loghub.Event 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());
}
Aggregations