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

[Filebeat][New Module] Mysql Enterprise Audit log #22273

Merged
merged 15 commits into from
Dec 9, 2020

Conversation

P1llus
Copy link
Member

@P1llus P1llus commented Oct 29, 2020

What does this PR do?

This creates a module that focuses on logs and files created by MySQL. Currently this only has support for Enterprise Audit logs but can be extended in the future.

Why is it important?

Adding support for more OOTB solutions for filebeat.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Field references: https://dev.mysql.com/doc/refman/8.0/en/audit-log-file-formats.html

@P1llus P1llus added enhancement Filebeat Filebeat Team:Services (Deprecated) Label for the former Integrations-Services team needs_reviewer PR needs to be assigned a reviewer Team:Security-External Integrations labels Oct 29, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations-services (Team:Services)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/security-external-integrations (Team:Security-External Integrations)

@botelastic botelastic bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Oct 29, 2020
@elasticmachine
Copy link
Collaborator

elasticmachine commented Oct 29, 2020

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #22273 updated

  • Start Time: 2020-12-08T02:25:59.854+0000

  • Duration: 48 min 54 sec

Test stats 🧪

Test Results
Failed 0
Passed 5094
Skipped 566
Total 5660

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 5094
Skipped 566
Total 5660

@elasticmachine
Copy link
Collaborator

elasticmachine commented Oct 29, 2020

💚 Flaky test report

Tests succeeded.

Expand to view the summary

Test stats 🧪

Test Results
Failed 0
Passed 4504
Skipped 561
Total 5065

Copy link
Contributor

@leehinman leehinman left a comment

Choose a reason for hiding this comment

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

looking good.

filebeat/docs/fields.asciidoc Show resolved Hide resolved
filebeat/docs/fields.asciidoc Outdated Show resolved Hide resolved
filebeat/docs/fields.asciidoc Outdated Show resolved Hide resolved
filebeat/docs/fields.asciidoc Outdated Show resolved Hide resolved
@P1llus
Copy link
Member Author

P1llus commented Nov 10, 2020

After discussion whether we want to merge this with the current OSS module we decided to rename the module into mysqlenterprise.

Once this is created into a package, both the OSS and the X-Pack module will merge into one.

@P1llus
Copy link
Member Author

P1llus commented Nov 10, 2020

Seems to be getting there now. @sayden anything you would want to add to this as well?

"input.type": "log",
"log.offset": 0,
"mysqlenterprise.audit.class": "audit",
"mysqlenterprise.audit.connection_id": 0,

Choose a reason for hiding this comment

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

do we know what it means if you have a connection_id field at startup? Just wondering if we should try and figure out an ECS mapping for it or not

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think there is any. At first I tried to find a "session ID" field we could use in ECS; but it seems that the session ID is only unique to the current active connections, so it will reset and use the same connection_id for another connection later according to its docs:

https://dev.mysql.com/doc/refman/8.0/en/information-functions.html#function_connection-id

Do you know any other field that might match? I tried to look in client, user and network but could not find anything that matches well

"mysqlenterprise.audit.class": "connection",
"mysqlenterprise.audit.connection_data.connection_attributes._client_name": "libmysql",
"mysqlenterprise.audit.connection_data.connection_attributes._client_version": "8.0.22",
"mysqlenterprise.audit.connection_data.connection_attributes._os": "Linux",

Choose a reason for hiding this comment

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

should these map to host.os fields?

Copy link
Member Author

Choose a reason for hiding this comment

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

These should be in the client fields, connection_data is for client data and startup_data is for the host. However there was no *.os fields for client in the ECS definition :(

@P1llus
Copy link
Member Author

P1llus commented Nov 16, 2020

@andrewstucki Added a better test log example for processes, added most of the different fields and left comments on the rest.
Also added some extra process fields in case we wanted to use them, please let me know what you think.

Copy link
Contributor

@adriansr adriansr left a comment

Choose a reason for hiding this comment

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

All in all it's looking good, but I have a few little suggestions here in there.


This is a module for different types of MySQL logs. Currently focusing on data from the MySQL Enterprise Audit Plugin in JSON format.

To configure the the Enterprise Audit Plugin to output in JSON format please follow the directions in the https://dev.mysql.com/doc/refman/8.0/en/audit-log-file-formats.html[MySQL Documentation]
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Missing dot at the end.

Suggested change
To configure the the Enterprise Audit Plugin to output in JSON format please follow the directions in the https://dev.mysql.com/doc/refman/8.0/en/audit-log-file-formats.html[MySQL Documentation]
To configure the the Enterprise Audit Plugin to output in JSON format please follow the directions in the https://dev.mysql.com/doc/refman/8.0/en/audit-log-file-formats.html[MySQL Documentation.]

| login.ip | client.ip |
| startup_data.os_version | host.os.full |
| startup_data.args | process.args |
| onnection_attributes._pid | process.pid |
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
| onnection_attributes._pid | process.pid |
| connection_attributes._pid | process.pid |

MySQL Enterprise Audit fields are mapped to ECS in the following way:
[options="header"]
|==============================================================
| Check Point Fields | ECS Fields |
Copy link
Contributor

Choose a reason for hiding this comment

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

Is "Check Point" a concept in MySQL Audit logs or was this copied over from Check Point docs?

@@ -0,0 +1,10 @@
- key: mysqlenterprise
title: Mysql Enterprise
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
title: Mysql Enterprise
title: MySQL Enterprise

- key: mysqlenterprise
title: Mysql Enterprise
description: >
Mysql Enterprise Audit module
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

Suggested change
Mysql Enterprise Audit module
MySQL Enterprise Audit module

lang: painless
if: ctx?.process?.args != null
source: |
ctx.process.args_count = ctx.process.args.length - 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

According to ECS this should be the "length of the process.args array", not the length minus 1.

if: ctx?.process?.args != null
source: |
ctx.process.args_count = ctx.process.args.length - 1;
ctx.process.executable = ctx.process.args[0];
Copy link
Contributor

@adriansr adriansr Nov 26, 2020

Choose a reason for hiding this comment

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

Being extra paranoid here, this will cause an exception when process.args is an empty list (non-null, but zero length).


# Set paths for the log files when file input is used.
# Should only be used together with file input
# var.paths: /home/user/mysqlauditlogs/audit.*.log
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this won't work if the user uncomments the line, as vars.paths is expected to be a list not a string.

Suggested change
# var.paths: /home/user/mysqlauditlogs/audit.*.log
# var.paths:
# - /home/user/mysqlauditlogs/audit.*.log

@andrewstucki andrewstucki merged commit 03383be into elastic:master Dec 9, 2020
andrewstucki pushed a commit to andrewstucki/beats that referenced this pull request Dec 9, 2020
* initial stash of mysql module

* initial commit for filebeat mysql module

* removing syslog from manifest currently

* changing module and field names to mysqlenterprise

* fixing some wrong types and adding related fields

* adding changelog entry

* adding some more process fields and event category/types

* fixing merge changelog

* adding changes based on PR feedback

(cherry picked from commit 03383be)
andrewstucki pushed a commit that referenced this pull request Dec 9, 2020
…dit log (#23021)

* [Filebeat][New Module] Mysql Enterprise Audit log (#22273)

* initial stash of mysql module

* initial commit for filebeat mysql module

* removing syslog from manifest currently

* changing module and field names to mysqlenterprise

* fixing some wrong types and adding related fields

* adding changelog entry

* adding some more process fields and event category/types

* fixing merge changelog

* adding changes based on PR feedback

(cherry picked from commit 03383be)

* regenerate docs

Co-authored-by: Marius Iversen <pillus@chasenet.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Filebeat Filebeat needs_reviewer PR needs to be assigned a reviewer Team:Services (Deprecated) Label for the former Integrations-Services team v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants