Created
July 26, 2018 17:08
-
-
Save jakelandis/7b0f5511c714e7f0e0f4f9a7b9b1fac8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//example log lines pulled from ingest grok tests: https://github.com/elastic/elasticsearch/blob/master/libs/grok/src/test/java/org/elasticsearch/grok/GrokTests.java | |
//validated that dissect matches via it's unit tests | |
@BenchmarkMode(Mode.Throughput) | |
@OutputTimeUnit(TimeUnit.SECONDS) | |
@Warmup(iterations = 3, time = 5, timeUnit = TimeUnit.SECONDS) | |
@Measurement(iterations = 5, time = 30, timeUnit = TimeUnit.SECONDS) | |
@Threads(1) | |
@Fork(2) | |
public class DissectBenchmark { | |
private static final String SYSLOG_LINE = "Mar 16 00:01:25 evita postfix/smtpd[1713]: connect from camomile.cloud9.net[168.100.1.3]"; | |
private static final String APACHE_LINE = "31.184.238.164 - - [24/Jul/2014:05:35:37 +0530] \"GET /logs/access.log HTTP/1.0\" 200 69849 " + | |
"\"http://8rursodiol.enjin.com\" \"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) " + | |
"Chrome/30.0.1599.12785 YaBrowser/13.12.1599.12785 Safari/537.36\" \"www.dlwindianrailways.com\""; | |
private static Map<String, String> patterns = Grok.getBuiltinPatterns(); | |
@State(Scope.Thread) | |
public static class DissectSysLogSetup { | |
static final DissectParser DISSECTOR = new DissectParser("%{timestamp} %{+timestamp} %{+timestamp} %{logsource} %{program}[%{pid}]: %{message}", " "); | |
} | |
@State(Scope.Thread) | |
public static class DissectApacheLogSetup { | |
static final DissectParser DISSECTOR = new DissectParser("%{clientip} %{ident} %{auth} [%{timestamp}] \"%{verb} %{request} HTTP/%{httpversion}\" %{response} %{bytes} \"%{referrer}\" \"%{agent}\" %{->}", " "); | |
} | |
@State(Scope.Thread) | |
public static class GrokSysLogSetup { | |
static final Grok GROK = new Grok(patterns, "%{SYSLOGLINE}"); | |
} | |
@State(Scope.Thread) | |
public static class GrokApacheLogSetup { | |
static final Grok GROK = new Grok(patterns, "%{COMBINEDAPACHELOG}"); | |
} | |
@Benchmark | |
public void dissectSysLog(final Blackhole bh) { | |
bh.consume( | |
DissectSysLogSetup.DISSECTOR.parse(SYSLOG_LINE) | |
); | |
} | |
@Benchmark | |
public void dissectApacheLog(final Blackhole bh) { | |
bh.consume( | |
DissectApacheLogSetup.DISSECTOR.parse(APACHE_LINE) | |
); | |
} | |
@Benchmark | |
public void grokSysLog(final Blackhole bh) { | |
bh.consume( | |
GrokSysLogSetup.GROK.captures(SYSLOG_LINE) | |
); | |
} | |
@Benchmark | |
public void grokApacheLog(final Blackhole bh) { | |
bh.consume( | |
GrokApacheLogSetup.GROK.captures(APACHE_LINE) | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment