Hi,
My testing floor Filebeat config:
filebeat.inputs:
- type: log
paths:
- /tmp/inputs_files/*
processors:
- dissect:
tokenizer: "JSON Authentication: %{json_string}"
field: "message" # we're verbose for clarity but the default is "message"
target_prefix: "" # put the json_string field at the root of the document
- decode_json_fields:
fields: ["json_string"]
target: "json"
output.file:
path: "/output/filebeat"
filename: filebeat
permissions: 0777
codec.json:
pretty: true
setup.template.enabled: false
xpack.monitoring.enabled: false
logging.json: true
logging.level: info
Content of /tmp/inputs_files/test.log:
JSON Authentication: {"timestamp": "2019-06-04T10:15:23.174830-0300", "type": "Authentication", "Authentication": {"version": {"major": 1, "minor": 0}, "status": "NT_STATUS_OK", "localAddress": null, "remoteAddress": "ipv4:ip:port", "serviceDescription": "Kerberos KDC", "authDescription": "ENC-TS Pre-authentication", "clientDomain": null, "clientAccount": "account@domain", "workstation": null, "becameAccount": "account", "becameDomain": "DOMAIN", "becameSid": "S-1-5-21-310888293-2901519497-23123456789-1113", "mappedAccount": "account", "mappedDomain": "DOMAIN", "netlogonComputer": null, "netlogonTrustAccount": null, "netlogonNegotiateFlags": "0x00000000", "netlogonSecureChannelType": 0, "netlogonTrustAccountSid": null, "passwordType": "aes256-cts-hmac-sha1-96", "duration": 9595}}
Resulting content in /output/filebeat/filebeat:
{
"@timestamp": "2019-06-06T06:07:05.488Z",
"@metadata": {
"beat": "filebeat",
"type": "_doc",
"version": "7.0.0"
},
"agent": {
"id": "37ddd7d3-90a7-44a7-ab5d-577c148084ff",
"version": "7.0.0",
"type": "filebeat",
"ephemeral_id": "61b3a4cc-86b6-44fe-b2dd-ce7462998006",
"hostname": "44eb8f3d7558"
},
"log": {
"offset": 0,
"file": {
"path": "/tmp/inputs_files/test.log"
}
},
"message": "JSON Authentication: {\"timestamp\": \"2019-06-04T10:15:23.174830-0300\", \"type\": \"Authentication\", \"Authentication\": {\"version\": {\"major\": 1, \"minor\": 0}, \"status\": \"NT_STATUS_OK\", \"localAddress\": null, \"remoteAddress\": \"ipv4:ip:port\", \"serviceDescription\": \"Kerberos KDC\", \"authDescription\": \"ENC-TS Pre-authentication\", \"clientDomain\": null, \"clientAccount\": \"account@domain\", \"workstation\": null, \"becameAccount\": \"account\", \"becameDomain\": \"DOMAIN\", \"becameSid\": \"S-1-5-21-310888293-2901519497-23123456789-1113\", \"mappedAccount\": \"account\", \"mappedDomain\": \"DOMAIN\", \"netlogonComputer\": null, \"netlogonTrustAccount\": null, \"netlogonNegotiateFlags\": \"0x00000000\", \"netlogonSecureChannelType\": 0, \"netlogonTrustAccountSid\": null, \"passwordType\": \"aes256-cts-hmac-sha1-96\", \"duration\": 9595}}",
"input": {
"type": "log"
},
"json_string": "{\"timestamp\": \"2019-06-04T10:15:23.174830-0300\", \"type\": \"Authentication\", \"Authentication\": {\"version\": {\"major\": 1, \"minor\": 0}, \"status\": \"NT_STATUS_OK\", \"localAddress\": null, \"remoteAddress\": \"ipv4:ip:port\", \"serviceDescription\": \"Kerberos KDC\", \"authDescription\": \"ENC-TS Pre-authentication\", \"clientDomain\": null, \"clientAccount\": \"account@domain\", \"workstation\": null, \"becameAccount\": \"account\", \"becameDomain\": \"DOMAIN\", \"becameSid\": \"S-1-5-21-310888293-2901519497-23123456789-1113\", \"mappedAccount\": \"account\", \"mappedDomain\": \"DOMAIN\", \"netlogonComputer\": null, \"netlogonTrustAccount\": null, \"netlogonNegotiateFlags\": \"0x00000000\", \"netlogonSecureChannelType\": 0, \"netlogonTrustAccountSid\": null, \"passwordType\": \"aes256-cts-hmac-sha1-96\", \"duration\": 9595}}",
"json": {
"Authentication": {
"status": "NT_STATUS_OK",
"remoteAddress": "ipv4:ip:port",
"authDescription": "ENC-TS Pre-authentication",
"netlogonSecureChannelType": 0,
"netlogonTrustAccountSid": null,
"serviceDescription": "Kerberos KDC",
"becameAccount": "account",
"duration": 9595,
"netlogonTrustAccount": null,
"version": {
"major": 1,
"minor": 0
},
"clientDomain": null,
"becameDomain": "DOMAIN",
"becameSid": "S-1-5-21-310888293-2901519497-23123456789-1113",
"mappedAccount": "account",
"mappedDomain": "DOMAIN",
"netlogonComputer": null,
"localAddress": null,
"clientAccount": "account@domain",
"workstation": null,
"netlogonNegotiateFlags": "0x00000000",
"passwordType": "aes256-cts-hmac-sha1-96"
},
"timestamp": "2019-06-04T10:15:23.174830-0300",
"type": "Authentication"
},
"ecs": {
"version": "1.0.0"
},
"host": {
"name": "44eb8f3d7558"
}
}
Valid variation of the tokenizer:
tokenizer: "%{}: %{json_string}"
Refs:
https://www.elastic.co/guide/en/beats/filebeat/7.0/dissect.html
https://www.elastic.co/guide/en/beats/filebeat/7.0/decode-json-fields.html
https://www.elastic.co/guide/en/logstash/current/plugins-filters-dissect.html
[
{
"name": "When all the defined fields are captured by we have remaining data",
"tok": "level=%{level} ts=%{timestamp} caller=%{caller} msg=\"%{message}\"",
"msg": "level=info ts=2018-06-27T17:19:13.036579993Z caller=main.go:222 msg=\"Starting OK\" version=\"(version=2.3.1, branch=HEAD, revision=188ca45bd85ce843071e768d855722a9d9dabe03)\"}",
"expected": {
"caller": "main.go:222",
"level": "info",
"message": "Starting OK",
"timestamp": "2018-06-27T17:19:13.036579993Z"
},
"skip": false,
"fail": false
},
{
"name": "Complex stack trace",
"tok": "%{day}-%{month}-%{year} %{hour} %{severity} [%{thread_id}] %{origin} %{message}",
"msg": "18-Apr-2018 06:53:20.411 INFO [http-nio-8080-exec-1] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header\n Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.\n java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens\n at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:426)\n at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:687)\n at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)\n at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)\n at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)\n at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)\n at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)\n at java.lang.Thread.run(Thread.java:748)",
"expected": {
"day": "18",
This file has been truncated. show original
Note 1:
I'm not saying the dissect processor in Beats is exactly like the logstash dissect filter.
As far as me reading the doc, source codes, the tests in the sources, github, the spec, they aren't.
But the filebeat dissect processor documentation page is thin and not up to date currently so you have to fall back on the logstash doc, the spec, the tests and the source codes to obtain knowledge and corrections to that knowledge when required. Of course simply empirically testing the hell out of the thing also works but you can't test for something you don't know is a feature...
Note 2:
There is a max_depth setting for the decode_json_fields processor. In your case it doesn't kick in and doesn't bound the deptness of the json object. I have experimented with different cases and I can make it kick in when I ingest json lines which contains escaped json strings in string fields. But even after reading the code and the github issues and forum posts I could find. I still don't quite understand it enough to explain it to someone else, logically. So I'll refrain from discussing this aspect at this point. I'm a bit confused by that setting currently.
Again it doesn't apply to your example, whatever you set it to.