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

Drop not audit logs in elasticsearch/audit fileset ingest pipeline #30164

Merged
merged 5 commits into from
Feb 7, 2022

Conversation

tetianakravchenko
Copy link
Contributor

Signed-off-by: Tetiana Kravchenko [email protected]

What does this PR do?

drop log message in elasticsearch/audit ingest pipeline if it is not an audit log.

in ingest pipelines there are defined drop as a first step - for server, slowlog, and deprecation

there is no drop defined for audit logs - https://github.com/elastic/beats/blob/master/filebeat/module/elasticsearch/audit/ingest/pipeline-json.yml

as a result there might be logs duplications - as described in #16540
note: it is not related to the kubernetes itself, in case audit and other log will be written to the same file - there will be the same problem.

Why is it important?

Avoid logs duplication in different filesets.

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.

How to test this PR locally

Related issues

Use cases

Screenshots

Before adjustments:
Screenshot 2022-02-01 at 09 48 07

After:

Screenshot 2022-02-02 at 16 01 57

Logs

@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Feb 2, 2022
@mergify
Copy link
Contributor

mergify bot commented Feb 2, 2022

This pull request does not have a backport label. Could you fix it @tetianakravchenko? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v./d./d./d is the label to automatically backport to the 7./d branch. /d is the digit

NOTE: backport-skip has been added to this pull request.

@tetianakravchenko tetianakravchenko added the Team:Integrations Label for the Integrations team label Feb 2, 2022
@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Feb 2, 2022
@botelastic botelastic bot removed the needs_team Indicates that the issue/PR needs a Team:* label label Feb 2, 2022
@elasticmachine
Copy link
Collaborator

Pinging @elastic/integrations (Team:Integrations)

field: event.type
path: elasticsearch.audit
- drop:
if: '!["rest", "transport", "ip_filter", "security_config_change"].contains(ctx.elasticsearch?.audit?.event?.type)'
Copy link
Contributor Author

@tetianakravchenko tetianakravchenko Feb 2, 2022

Choose a reason for hiding this comment

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

it would be much easier to use ctx.elasticsearch.audit.type != 'audit', but as I see this field was introduced only in version 7.3 - elastic/elasticsearch#42887 (docker - https://github.com/elastic/elasticsearch/blob/7.3/distribution/docker/docker-build-context/src/docker/config/log4j2.properties and in core - https://github.com/elastic/elasticsearch/blob/7.3/x-pack/plugin/core/src/main/config/log4j2.properties#L6), in version 7.1 it was not yet available https://github.com/elastic/elasticsearch/blob/7.1/x-pack/plugin/core/src/main/config/log4j2.properties

would it maybe be file to drop support for < 7.3 ?

from the doc it looks like event.type should be a good filter for audit logs, or am I missing smth?

@elasticmachine
Copy link
Collaborator

elasticmachine commented Feb 2, 2022

💚 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 preview

Expand to view the summary

Build stats

  • Start Time: 2022-02-07T12:35:19.133+0000

  • Duration: 40 min 47 sec

Test stats 🧪

Test Results
Failed 0
Passed 980
Skipped 192
Total 1172

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@elasticmachine
Copy link
Collaborator

Pinging @elastic/stack-monitoring (Stack monitoring)

@sayden sayden self-requested a review February 2, 2022 16:56
@matschaffer matschaffer requested a review from pgomulka February 3, 2022 06:57
@matschaffer
Copy link
Contributor

Makes some sense to me. Thinking it might be good to have @pgomulka review this, especially since he recently helped pull log samples for ES 8.0

Copy link
Contributor

@pgomulka pgomulka left a comment

Choose a reason for hiding this comment

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

I left few questions

Copy link
Contributor

@pgomulka pgomulka left a comment

Choose a reason for hiding this comment

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

LGTM

@tetianakravchenko
Copy link
Contributor Author

/test

Signed-off-by: Tetiana Kravchenko <[email protected]>
Signed-off-by: Tetiana Kravchenko <[email protected]>
@tetianakravchenko
Copy link
Contributor Author

/test

@tetianakravchenko tetianakravchenko merged commit 1e72124 into elastic:main Feb 7, 2022
@tetianakravchenko tetianakravchenko added the backport-v8.0.0 Automated backport with mergify label Feb 7, 2022
mergify bot pushed a commit that referenced this pull request Feb 7, 2022
…30164)

* adjust elasticsearch/audit fileset

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix formatting

Signed-off-by: Tetiana Kravchenko <[email protected]>

* adjust drop condition; revert test case for docker

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix typos

Signed-off-by: Tetiana Kravchenko <[email protected]>

* remove 'remove' of user.name field in pipeline-json for elasticsearch/audit

Signed-off-by: Tetiana Kravchenko <[email protected]>
(cherry picked from commit 1e72124)
tetianakravchenko added a commit that referenced this pull request Feb 14, 2022
…30164) (#30239)

* adjust elasticsearch/audit fileset

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix formatting

Signed-off-by: Tetiana Kravchenko <[email protected]>

* adjust drop condition; revert test case for docker

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix typos

Signed-off-by: Tetiana Kravchenko <[email protected]>

* remove 'remove' of user.name field in pipeline-json for elasticsearch/audit

Signed-off-by: Tetiana Kravchenko <[email protected]>
(cherry picked from commit 1e72124)

Co-authored-by: Tetiana Kravchenko <[email protected]>
matschaffer added a commit to matschaffer/beats that referenced this pull request Feb 17, 2022
test-audit-docker.log also contains a case but it was overlooked in the expected file until elastic#30164 added the appropriate drop statements.
mergify bot added a commit that referenced this pull request Feb 17, 2022
…30164) (#30239)

* adjust elasticsearch/audit fileset

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix formatting

Signed-off-by: Tetiana Kravchenko <[email protected]>

* adjust drop condition; revert test case for docker

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix typos

Signed-off-by: Tetiana Kravchenko <[email protected]>

* remove 'remove' of user.name field in pipeline-json for elasticsearch/audit

Signed-off-by: Tetiana Kravchenko <[email protected]>
(cherry picked from commit 1e72124)

Co-authored-by: Tetiana Kravchenko <[email protected]>
(cherry picked from commit 32ecd20)
matschaffer added a commit that referenced this pull request Feb 21, 2022
…h logs (#30440)

* Ensure we drop server logs that show up in deprecation pipeline

* Add note about deprecation dataset normalization

* Add test for mixed es server logs

This pipeline already contained a drop to avoid duplicate logging.

* Ensure we drop server logs that show up in slowlog pipeline

This was partially guarded against in testing due to the grok on `elasticsearch.slowlog` but probably better to explicitly drop and avoid duplicate logging.

* Add "mixed" test for elasticsearch audit logs

test-audit-docker.log also contains a case but it was overlooked in the expected file until #30164 added the appropriate drop statements.

* Changelog entry

* Remove duplicatd filebeat header
mergify bot pushed a commit that referenced this pull request Feb 21, 2022
…h logs (#30440)

* Ensure we drop server logs that show up in deprecation pipeline

* Add note about deprecation dataset normalization

* Add test for mixed es server logs

This pipeline already contained a drop to avoid duplicate logging.

* Ensure we drop server logs that show up in slowlog pipeline

This was partially guarded against in testing due to the grok on `elasticsearch.slowlog` but probably better to explicitly drop and avoid duplicate logging.

* Add "mixed" test for elasticsearch audit logs

test-audit-docker.log also contains a case but it was overlooked in the expected file until #30164 added the appropriate drop statements.

* Changelog entry

* Remove duplicatd filebeat header

(cherry picked from commit 7b67384)
mergify bot pushed a commit that referenced this pull request Feb 21, 2022
…h logs (#30440)

* Ensure we drop server logs that show up in deprecation pipeline

* Add note about deprecation dataset normalization

* Add test for mixed es server logs

This pipeline already contained a drop to avoid duplicate logging.

* Ensure we drop server logs that show up in slowlog pipeline

This was partially guarded against in testing due to the grok on `elasticsearch.slowlog` but probably better to explicitly drop and avoid duplicate logging.

* Add "mixed" test for elasticsearch audit logs

test-audit-docker.log also contains a case but it was overlooked in the expected file until #30164 added the appropriate drop statements.

* Changelog entry

* Remove duplicatd filebeat header

(cherry picked from commit 7b67384)
tetianakravchenko pushed a commit that referenced this pull request Feb 21, 2022
…30164) (#30239) (#30447)

* adjust elasticsearch/audit fileset

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix formatting

Signed-off-by: Tetiana Kravchenko <[email protected]>

* adjust drop condition; revert test case for docker

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix typos

Signed-off-by: Tetiana Kravchenko <[email protected]>

* remove 'remove' of user.name field in pipeline-json for elasticsearch/audit

Signed-off-by: Tetiana Kravchenko <[email protected]>
(cherry picked from commit 1e72124)

Co-authored-by: Tetiana Kravchenko <[email protected]>
(cherry picked from commit 32ecd20)

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
matschaffer added a commit that referenced this pull request Feb 22, 2022
…h logs (#30440) (#30488)

* Ensure we drop server logs that show up in deprecation pipeline

* Add note about deprecation dataset normalization

* Add test for mixed es server logs

This pipeline already contained a drop to avoid duplicate logging.

* Ensure we drop server logs that show up in slowlog pipeline

This was partially guarded against in testing due to the grok on `elasticsearch.slowlog` but probably better to explicitly drop and avoid duplicate logging.

* Add "mixed" test for elasticsearch audit logs

test-audit-docker.log also contains a case but it was overlooked in the expected file until #30164 added the appropriate drop statements.

* Changelog entry

* Remove duplicatd filebeat header

(cherry picked from commit 7b67384)

Co-authored-by: Mat Schaffer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify backport-v8.0.0 Automated backport with mergify Feature:Stack Monitoring Team:Integrations Label for the Integrations team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Filebeat] Elasticsearch Module w/ Kubernetes Autodiscover Causes Logs in Incorrect Fieldsets
5 participants