{"action":"created","issue":{"url":"https://api.github.com/repos/mozilla-services/heka/issues/1842","repository_url":"https://api.github.com/repos/mozilla-services/heka","labels_url":"https://api.github.com/repos/mozilla-services/heka/issues/1842/labels{/name}","comments_url":"https://api.github.com/repos/mozilla-services/heka/issues/1842/comments","events_url":"https://api.github.com/repos/mozilla-services/heka/issues/1842/events","html_url":"https://github.com/mozilla-services/heka/pull/1842","id":128941944,"number":1842,"title":"Implementation of a multiline splitter","user":{"login":"relistan","id":267761,"avatar_url":"https://avatars.githubusercontent.com/u/267761?v=3","gravatar_id":"","url":"https://api.github.com/users/relistan","html_url":"https://github.com/relistan","followers_url":"https://api.github.com/users/relistan/followers","following_url":"https://api.github.com/users/relistan/following{/other_user}","gists_url":"https://api.github.com/users/relistan/gists{/gist_id}","starred_url":"https://api.github.com/users/relistan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/relistan/subscriptions","organizations_url":"https://api.github.com/users/relistan/orgs","repos_url":"https://api.github.com/users/relistan/repos","events_url":"https://api.github.com/users/relistan/events{/privacy}","received_events_url":"https://api.github.com/users/relistan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-01-26T21:04:39Z","updated_at":"2016-03-16T17:17:21Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mozilla-services/heka/pulls/1842","html_url":"https://github.com/mozilla-services/heka/pull/1842","diff_url":"https://github.com/mozilla-services/heka/pull/1842.diff","patch_url":"https://github.com/mozilla-services/heka/pull/1842.patch"},"body":"We work with a lot of Java and Scala stacktraces and the other options I've tried for supporting them in Heka don't work as well as I'd like. This is an implementation of a regex-based `MultilineSplitter` which works great for our stacktraces. The implementation is that you define a regex to use as the delimiter and a regex used to match lines that should be joined together. It first splits the buffer using the delimiter and then checks each section against the multiline regex to see if it's a match. All lines that are contiguous and match the multiline regex are joined. Because of the multiline nature, it always keeps the delimiter on the EOL.\r\n\r\nThis is going to be notably slower than the `RegexSplitter` because it has to find many matches on the first pass rather than the first one. (That's limited to 99 by default and is not currently configurable without a recompile.) Secondly, it will run a second regex on all those matches. Given's Go's performance-oriented Regex implementation and reasonable logging levels it appears to be tolerable. It can, in the worst case, re-split the first lines in a very large buffer repeatedly.\r\n\r\nHere's an example configuration for the splitter:\r\n```toml\r\n[multiline_splitter]\r\ntype = \"MultilineSplitter\"\r\nmultiline = '(\\] FATAL )|(\\A\\s*.+Exception: .)|(at \\S+\\(\\S+\\))|(\\A\\s+... \\d+ more)|(\\A\\s*Caused by:.)|(\\A\\s*Grave:)'\r\ndelimiter = '\\n'\r\n```\r\nGiven a broken Kafka installation, this generates something like the following when encoded with the `ESLogstashV0Encoder`:\r\n```json\r\n{\r\n  \"@fields\": {\r\n    \"ContainerName\": \"boring_bohr\",\r\n    \"ContainerID\": \"910f097243d6\"\r\n  },\r\n  \"@source_host\": \"docker1\",\r\n  \"@uuid\": \"bda1cb47-8aa4-420e-9316-543364afd5fc\",\r\n  \"@timestamp\": \"2016-01-24T14:22:17\",\r\n  \"@type\": \"message\",\r\n  \"@logger\": \"stdout\",\r\n  \"@severity\": 7,\r\n  \"@message\": \"java.net.ConnectException: Connection refused\\n\\tat sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)\\n\\tat sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716)\\n\\tat org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:361)\\n\\tat org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1081)\\n\",\r\n  \"@envversion\": \"\",\r\n  \"@pid\": 0\r\n}\r\n```\r\nNote that this output is from a splitter-enabled Docker input plugin that I will prepare a separate PR for."},"comment":{"url":"https://api.github.com/repos/mozilla-services/heka/issues/comments/197439515","html_url":"https://github.com/mozilla-services/heka/pull/1842#issuecomment-197439515","issue_url":"https://api.github.com/repos/mozilla-services/heka/issues/1842","id":197439515,"user":{"login":"relistan","id":267761,"avatar_url":"https://avatars.githubusercontent.com/u/267761?v=3","gravatar_id":"","url":"https://api.github.com/users/relistan","html_url":"https://github.com/relistan","followers_url":"https://api.github.com/users/relistan/followers","following_url":"https://api.github.com/users/relistan/following{/other_user}","gists_url":"https://api.github.com/users/relistan/gists{/gist_id}","starred_url":"https://api.github.com/users/relistan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/relistan/subscriptions","organizations_url":"https://api.github.com/users/relistan/orgs","repos_url":"https://api.github.com/users/relistan/repos","events_url":"https://api.github.com/users/relistan/events{/privacy}","received_events_url":"https://api.github.com/users/relistan/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T17:17:21Z","updated_at":"2016-03-16T17:17:21Z","body":"@rafrombrc I know you don't have much time for this these days (been there with my own open source projects). Would very much appreciate a review if you can get the time."}}