Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql: Add script processor to fix grok behaviour of ES 8.7.x+ #6531

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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": {
Copy link
Member

@andrewkroh andrewkroh Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a description and a tag to the script processors. This helps in debugging.

The description field documents what the script does which helps other developers and it is displayed in the Ingest Pipeline editor in Kibana. The tag field is included in the error message metadata and ingest node stats to help distinguish between script processors.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure @andrewkroh!

"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