Thanks for the script. I tried that however Im getting the this error:
{
"root_cause": [
{
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... cher(doc['event.original');\r\nif (match.matches()) ...",
" ^---- HERE"
],
"script": "Matcher match = /User <(.*)> IP/.matcher(doc['event.original');\r\nif (match.matches()) {\r\n return match.group(1);\r\n} else {\r\n return 'no user found';\r\n}",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "filebeat-7.6.2-2020.04.24-000001",
"node": "I0KYH24DQNyyw57l5GaA0g",
"reason": {
"type": "script_exception",
"reason": "compile error",
"script_stack": [
"... cher(doc['event.original');\r\nif (match.matches()) ...",
" ^---- HERE"
],
"script": "Matcher match = /User <(.*)> IP/.matcher(doc['event.original');\r\nif (match.matches()) {\r\n return match.group(1);\r\n} else {\r\n return 'no user found';\r\n}",
"lang": "painless",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "invalid sequence of tokens near [')'].",
"caused_by": {
"type": "no_viable_alt_exception",
"reason": null
}
}
}
}
]
}
I've tried to add the missing bracket doc['event.original']); but this spits out a new error:
{
"root_cause": [
{
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"match = /User <(.*)> IP/.matcher(doc['event.original']);\r\n",
" ^---- HERE"
],
"script": "Matcher match = /User <(.*)> IP/.matcher(doc['event.original']);\r\nif (match.matches()) {\r\n return match.group(1);\r\n} else {\r\n return 'no user found';\r\n}",
"lang": "painless"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "filebeat-7.6.2-2020.04.24-000001",
"node": "I0KYH24DQNyyw57l5GaA0g",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"match = /User <(.*)> IP/.matcher(doc['event.original']);\r\n",
" ^---- HERE"
],
"script": "Matcher match = /User <(.*)> IP/.matcher(doc['event.original']);\r\nif (match.matches()) {\r\n return match.group(1);\r\n} else {\r\n return 'no user found';\r\n}",
"lang": "painless",
"caused_by": {
"type": "class_cast_exception",
"reason": "class org.elasticsearch.index.fielddata.ScriptDocValues$Strings cannot be cast to class java.lang.CharSequence (org.elasticsearch.index.fielddata.ScriptDocValues$Strings is in unnamed module of loader 'app'; java.lang.CharSequence is in module java.base of loader 'bootstrap')"
}
}
}
]
}
Any ideas?