Skip to content

Commit

Permalink
mysql: Add script processor to fix grok behaviour of ES 8.7.x+ (#6531)
Browse files Browse the repository at this point in the history
  • Loading branch information
shmsr committed Jun 28, 2023
1 parent 6152bc5 commit 588f75c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ SELECT last_name, MAX(salary) AS salary FROM employees
INNER JOIN salaries ON employees.emp_no = salaries.emp_no
GROUP BY last_name
ORDER BY salary DESC
LIMIT 10;
LIMIT 10;
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,30 @@
"ignore_missing": true
}
},
{
"script": {
"lang": "painless",
"if": "ctx?.mysql != null",
"source": "for (field in params.fields) { if (ctx.mysql[field] instanceof List) { def vals = ctx.mysql[field]; vals = vals.stream().distinct().collect(Collectors.toList()); if (vals.size() == 1) { ctx.mysql[field] = vals[0] } else { ctx.mysql[field] = vals } } }",
"params": {
"fields": [
"thread_id"
]
}
}
},
{
"script": {
"lang": "painless",
"if": "ctx?.mysql?.slowlog != null",
"source": "for (field in params.fields) { if (ctx.mysql.slowlog[field] instanceof List) { def vals = ctx.mysql.slowlog[field]; vals = vals.stream().distinct().collect(Collectors.toList()); if (vals.size() == 1) { ctx.mysql.slowlog[field] = vals[0] } else { ctx.mysql.slowlog[field] = vals } } }",
"params": {
"fields": [
"schema"
]
}
}
},
{
"remove": {
"field": "message"
Expand Down

0 comments on commit 588f75c

Please sign in to comment.