-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
out_stackdriver: add project_id_key override to allow specifying gcp project id from the record #8209
out_stackdriver: add project_id_key override to allow specifying gcp project id from the record #8209
Conversation
Thank you for the PR! I am sorry that I didn't see the issue opened last week, thank you for opening a PR about it. This seems like a good change that we'll probably accept, however I think it would be best for it to match the implementation of the other special keys. Generally with other special keys that this plugin recognizes, we have a default in the format You can see for example where severity key is defined in the header:
Then we have config options for alternatives to those keys to be specified: fluent-bit/plugins/out_stackdriver/stackdriver.c Line 2987 in 8733b25
What you have is most of the way to what is needed. The changes would essentially be:
Once those changes are made, I'm happy to accept the change! (P.S. for that DCO check; all commits in this repo are required to be signed, so that's |
@@ -2410,8 +2415,19 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx, | |||
} | |||
|
|||
/* logName */ | |||
len = snprintf(path, sizeof(path) - 1, | |||
project_key_extracted = FLB_FALSE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the extraction here should be moved up with the rest of the extractions, like line 2212ish.
The /* logName */
comment should also be moved down to where the log name check is now.
58da0a3
to
0eed9ec
Compare
@braydonk I appreciate the quick review and the feedback! I just force pushed the latest changes... I hope this is in line with your comments. If I missed anything please let me know and I'll give it another shot! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! One last thing
@@ -2410,8 +2422,13 @@ static flb_sds_t stackdriver_format(struct flb_stackdriver *ctx, | |||
} | |||
|
|||
/* logName */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment needs to be moved down to where the logName
section is (line 2432)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missed that one... Just pushed the latest commit!
0eed9ec
to
670d4a1
Compare
670d4a1
to
dec9f21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the useful feature and for working with me in the review!
Thank you for guiding me through it @braydonk! I really appreciate the help! |
Closes fluent#8195 Signed-off-by: ryanohnemus <[email protected]>
dec9f21
to
60919e5
Compare
@braydonk I had to push another commit to fix the memory leak due to not cleaning up the extract project_id_key, so this will probably need another review/approval to kick off the workflow tests again. I ran
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the action failed is a flake.
Thank you for the PR!
I'm happy to have been able to contribute! As far as merging goes, does that happen in a standard cadence after approvals? (Not sure if I need to do anything else for this PR) Do I wait until this is fully merged to create a documentation pull request? (Or will someone else handle the documentation update after merge?) |
I've got the Doc PR ready (added it into the description of this PR). I was intending to merge this here now, but it turns out there's a file here we aren't covered as a CODEOWNER where we should be (the testdata file). I'm going to file a separate PR to get us added to that so I can subsequently merge this one. |
Opened the CODEOWNERS PR here: #8254 |
Closes fluent#8195 Signed-off-by: ryanohnemus <[email protected]>
Closes fluent#8195 Signed-off-by: ryanohnemus <[email protected]> Signed-off-by: ahspw <[email protected]>
A new configuration option for the out_stackdriver plugin
project_id_key
allows you to specify a key within the jsonPayload that will be used to set the GCP Project ID to export to. This allows a stackdriver out plugin that has logWriter permissions in multiple projects to write to different gcp projects based on a jsonPayload (record) key. This also introduces a defaultlogging.googleapis.com/projectId
key that will be used if present in the record. The key that is used from the record is removed similar to howseverity_key
andlabel_key
work.Addresses #8195
Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
Docs PR: stackdriver: amend special fields docs fluent-bit-docs#1267
Configuration Parameters
PROJECT_ID
within LogEntrylogName
, which controls the gcp project that should receive these logs.Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.