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

feat(inputs.firehose): Add new plugin #15988

Merged
merged 9 commits into from
Jan 22, 2025
Merged

Conversation

syedmhashim
Copy link
Contributor

Summary

The firehose input plugin would be used to receive data from AWS Data Firehose.

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #15870

@telegraf-tiger telegraf-tiger bot added the feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin label Oct 7, 2024
@srebhan srebhan changed the title feat(inputs/firehose): add input plugin for AWS Data Firehose feat(inputs.firehose): Add new plugin Oct 8, 2024
@telegraf-tiger telegraf-tiger bot added the plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins label Oct 8, 2024
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

@syedmhashim I do have some comments, mostly on style, so overall this looks quite promising. I urge you to keep the code as simple and less nested as possible to ease review and debugging. And of course some unit-tests would be great!

plugins/inputs/firehose/README.md Outdated Show resolved Hide resolved
plugins/inputs/firehose/README.md Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
@srebhan srebhan self-assigned this Oct 8, 2024
@syedmhashim
Copy link
Contributor Author

@syedmhashim I do have some comments, mostly on style, so overall this looks quite promising. I urge you to keep the code as simple and less nested as possible to ease review and debugging. And of course some unit-tests would be great!

Thanks for the review. Will definitely go over the comments and update accordingly. Just FYI, I have been using http_listener_v2 input plugin as a reference to write the code. The unit tests will come soon as well

@srebhan
Copy link
Member

srebhan commented Oct 9, 2024

Yeah we do have some older code we didn't adapt yet but things changed both on the golang side as well as on us being more strict with the way things are done. ;-) No worries, we will figure it out together. :-)

@srebhan
Copy link
Member

srebhan commented Oct 10, 2024

@syedmhashim I'm loosing a bit the track in the discussion above, could you please push an update with the stuff that is clear and then we discuss the unclear parts?

@syedmhashim
Copy link
Contributor Author

@srebhan Hey! Just pushed some changes and commented "done" on the threads that I resolved. Sorry for the delay. I got occupied with my job

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

That looks much better @syedmhashim! Some more cleanups and comments from my side...

plugins/inputs/firehose/README.md Outdated Show resolved Hide resolved
plugins/inputs/firehose/README.md Outdated Show resolved Hide resolved
plugins/inputs/firehose/README.md Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose_request.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose_request.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose_request.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose_request.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose_request.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose_request.go Outdated Show resolved Hide resolved
@syedmhashim
Copy link
Contributor Author

@srebhan Hi! Pushed some changes and added comments where relevant

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

@syedmhashim thanks for the update. I tried to put more concrete suggestions into my review. Overall, I think we are almost there, the only thing missing are unit-tests with a mocked sender...

plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose_request.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/sample.conf Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose_request.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Really nice @syedmhashim! Some very small things with the biggest being that log messages should start with a captial letter... The only thing missing are the unit-tests...

plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
@syedmhashim
Copy link
Contributor Author

Hi @srebhan. In addition to the changes that you suggested, I also made some changes to the code(see last commit) that I think would make it more clean and readable. P.S I think it also helps to achieve separation of concern since now all processing of the request is handled by firehose_request.go while firehose.go mostly focus on adding metrics:

Changes to :

  • firehose_request.go
    • Added newRequest method to handle the creation of request object and (gzip +) json decoding of the request body
    • Added processRequest method to handle the authentication, validation, base64 decoding and parameter extraction
    • I’ve tried to set the response status code mostly in firehose_request.go
  • firehose.go
    • Added handleRequest method. This helps to get rid of the redundant sendResponse code block.

I'd like to hear your thoughts on this

@syedmhashim syedmhashim force-pushed the master branch 2 times, most recently from 0138d46 to 9d69797 Compare December 5, 2024 07:13
Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

@syedmhashim thanks for the update. I do have some smaller comments in the code but nothing big.

Regarding the tests, I suggest that you don't test the request separately but simply use a http client and send data to the plugin. You might also want to implement a general test-case setup similar to what we do in socket listener tests...

If you need help with the tests, please provide some payload examples and invite me to your branch and I'll help you to drive this PR over the finish line...

plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
plugins/inputs/firehose/firehose.go Outdated Show resolved Hide resolved
@syedmhashim
Copy link
Contributor Author

@srebhan Hey. Just sent you an invite! The payload needs to be in the following format with data having the actual b64 encoded text that would be parsed (based on the parser set) after decoding:

{
    "requestId": “test-id",
    "timestamp": 123456789,
    "records": [
        {
          "data": "aGVsbG8gd29ybGQK" // "hello world"
        }
    ]
}

@srebhan srebhan marked this pull request as ready for review December 19, 2024 18:04
@telegraf-tiger
Copy link
Contributor

Download PR build artifacts for linux_amd64.tar.gz, darwin_arm64.tar.gz, and windows_amd64.zip.
Downloads for additional architectures and packages are available below.

🥳 This pull request decreases the Telegraf binary size by -4.52 % for linux amd64 (new size: 261.2 MB, nightly size 273.6 MB)

📦 Click here to get additional PR build artifacts

Artifact URLs

DEB RPM TAR GZ ZIP
amd64.deb aarch64.rpm darwin_amd64.tar.gz windows_amd64.zip
arm64.deb armel.rpm darwin_arm64.tar.gz windows_arm64.zip
armel.deb armv6hl.rpm freebsd_amd64.tar.gz windows_i386.zip
armhf.deb i386.rpm freebsd_armv7.tar.gz
i386.deb ppc64le.rpm freebsd_i386.tar.gz
mips.deb riscv64.rpm linux_amd64.tar.gz
mipsel.deb s390x.rpm linux_arm64.tar.gz
ppc64el.deb x86_64.rpm linux_armel.tar.gz
riscv64.deb linux_armhf.tar.gz
s390x.deb linux_i386.tar.gz
linux_mips.tar.gz
linux_mipsel.tar.gz
linux_ppc64le.tar.gz
linux_riscv64.tar.gz
linux_s390x.tar.gz

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Dec 20, 2024
@srebhan srebhan assigned DStrand1 and unassigned srebhan Dec 20, 2024
@DStrand1 DStrand1 merged commit 1d4f089 into influxdata:master Jan 22, 2025
26 of 27 checks passed
@github-actions github-actions bot added this to the v1.34.0 milestone Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS Data Firehose HTTP Endpoint Input Plugin
3 participants