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

[AWS] Drop header log line in CloudFront events #5017

Merged
merged 5 commits into from
Jan 26, 2023
Merged

Conversation

0ccupi3R
Copy link
Contributor

By default the CloudFront stores these two lines as a header in each log file. Before this change it fails the pipeline and add message to error.message field.

Added the sample log line
#5016 6c95e22

CloudFront stores these two lines as a header in each log file. Before this change it fails the pipeline and add message to error.message field.

#Version: 1.0
#Fields: date time x-edge-location (TRUNCATED)
@0ccupi3R 0ccupi3R requested a review from a team as a code owner January 16, 2023 21:58
@elasticmachine
Copy link

elasticmachine commented Jan 16, 2023

💚 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: 2023-01-25T09:04:12.768+0000

  • Duration: 52 min 50 sec

Test stats 🧪

Test Results
Failed 0
Passed 179
Skipped 3
Total 182

🤖 GitHub comments

Expand to view the GitHub comments

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

  • /test : Re-trigger the build.

@zmoog zmoog self-requested a review January 17, 2023 07:59
@zmoog
Copy link
Contributor

zmoog commented Jan 17, 2023

Hey @0ccupi3R, thank you for taking the time to work on this contribution to the AWS integration!

You also created #5016 with a sample file for the tests. Could you please move that sample file to this PR? Having them all together in the same PR allows us to work and merge the change as a single unit of work.

Added header events which is available in each Cloud Front log file. `DROP` filter has added pipeline.
@0ccupi3R
Copy link
Contributor Author

Hello @zmoog

Thanks for picking it. Even though it was just a header line, I have added it to the sample log line within the same PR.

@andrewkroh andrewkroh changed the title Drop header log line in CloudFront events [AWS] Drop header log line in CloudFront events Jan 18, 2023
@zmoog
Copy link
Contributor

zmoog commented Jan 20, 2023

For the records, I see the Elastic Agent integration uses a 'local' processor to filter out the logs comments before sending:

processors:
- drop_event:
when:
regexp:
message: "^#.*"

So when the Agent runs with the DEBUG log level we can see the following message:

[elastic_agent.filebeat
][debug
] Pipeline client receives callback 'onFilteredOut' for event: {Timestamp: 2023-01-20 03: 52: 03.775055087 +0000 UTC Meta: {
        "_id": "cd1aa7d915-000000000000",
        "input_id": "aws-s3-cloudfront-7efa1443-a33f-4852-bd84-b325aac7b311",
        "raw_index": "logs-aws.cloudfront_logs-default"
    } Fields: {
        "aws": {
            "s3": {
                "bucket": {
                    "arn": "arn:aws:s3:::zmoog-dev-cloudfront-standard-logs",
                    "name": "zmoog-dev-cloudfront-standard-logs"
                },
                "object": {
                    "key": "logs/EA060IVQIIUAL.2023-01-20-03.335883cd.gz"
                }
            }
        },
        "cloud": {
            "provider": "",
            "region": "eu-west-1"
        },
        "input": {
            "type": "aws-s3"
        },
        "log": {
            "file": {
                "path": "https://zmoog-dev-cloudfront-standard-logs.s3.eu-west-1.amazonaws.com/logs/EA060IVQIIUAL.2023-01-20-03.335883cd.gz"
            },
            "offset": 0
        },
        "message": "#Version: 1.0",
        "tags": [
            "preserve_original_event",
            "forwarded",
            "aws-cloudfront"
        ]
    } Private: 0x4000c96600 TimeSeries: false
}

I can see it contains "message":"#Version: 1.0".

@0ccupi3R, are you using the Elastic Agent to ingest the CloudFront standard logs?

@zmoog
Copy link
Contributor

zmoog commented Jan 20, 2023

It's worth dropping invalid loglines to avoid errors.

@zmoog
Copy link
Contributor

zmoog commented Jan 20, 2023

/test

@elasticmachine
Copy link

elasticmachine commented Jan 20, 2023

🌐 Coverage report

Name Metrics % (covered/total) Diff
Packages 100.0% (14/14) 💚
Files 93.333% (14/15) 👎 -6.667
Classes 93.333% (14/15) 👎 -6.667
Methods 85.271% (220/258) 👎 -10.596
Lines 96.024% (5917/6162) 👍 0.256
Conditionals 100.0% (0/0) 💚

@zmoog
Copy link
Contributor

zmoog commented Jan 24, 2023

/test

@zmoog zmoog self-assigned this Jan 24, 2023
@zmoog
Copy link
Contributor

zmoog commented Jan 24, 2023

/test

2 similar comments
@zmoog
Copy link
Contributor

zmoog commented Jan 24, 2023

/test

@zmoog
Copy link
Contributor

zmoog commented Jan 25, 2023

/test

@zmoog zmoog merged commit 200271f into elastic:main Jan 26, 2023
@elasticmachine
Copy link

Package aws - 1.29.1 containing this change is available at https://epr.elastic.co/search?package=aws

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants