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

support retention for cloudwatch_logs output #2739

Merged
merged 1 commit into from
Nov 24, 2020

Conversation

shogo82148
Copy link
Contributor

support retention for cloudwatch_logs output plugin.
introduce a new property log_retention_days.

Addresses #2691


Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • Debug log output from testing the change
  • Attached Valgrind output that shows no leaks or memory corruption was found

Documentation

  • Documentation required for this feature

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.

@shogo82148 shogo82148 force-pushed the introduce-log-retention-days branch from 02d3169 to bfe8988 Compare October 31, 2020 12:02
@shogo82148 shogo82148 marked this pull request as ready for review October 31, 2020 13:30
@PettitWesley PettitWesley self-requested a review November 11, 2020 19:56
@PettitWesley PettitWesley self-assigned this Nov 11, 2020
@PettitWesley PettitWesley added the AWS Issues with AWS plugins or experienced by users running on AWS label Nov 11, 2020
@PettitWesley
Copy link
Contributor

Thank you for working on adding this to the new core cloudwatch logs plugin!

@PettitWesley
Copy link
Contributor

Per the contributing guide: https://github.com/fluent/fluent-bit/blob/master/CONTRIBUTING.md

You commit message should be something like: `out_cloudwatch_logs: add log_retention_days option"

@shogo82148 shogo82148 force-pushed the introduce-log-retention-days branch from bfe8988 to 1c04d31 Compare November 12, 2020 23:56
@shogo82148
Copy link
Contributor Author

Thanks. I updated the commit message.

Copy link
Contributor

@PettitWesley PettitWesley left a comment

Choose a reason for hiding this comment

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

Thanks again for contributing this. I added a few more comments (sorry, I didn't have time to do full review before). I also tested it- once these are fixed we can merge it.

If you have time, please also submit a PR to the docs repo and @ mention me on it: https://github.com/fluent/fluent-bit-docs

If not, let me know, and I will submit the PR for docs.

plugins/out_cloudwatch_logs/cloudwatch_api.c Outdated Show resolved Hide resolved
plugins/out_cloudwatch_logs/cloudwatch_api.c Outdated Show resolved Hide resolved
plugins/out_cloudwatch_logs/cloudwatch_api.c Outdated Show resolved Hide resolved
plugins/out_cloudwatch_logs/cloudwatch_logs.c Outdated Show resolved Hide resolved
Comment on lines +358 to +360
{"put_retention_policy_success", flb_test_cloudwatch_put_retention_policy_success },
{"already_exists_create_group_put_retention_policy", flb_test_cloudwatch_already_exists_create_group_put_retention_policy },
{"error_put_retention_policy", flb_test_cloudwatch_error_put_retention_policy },
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding tests!

@shogo82148 shogo82148 force-pushed the introduce-log-retention-days branch from 1c04d31 to 08e1850 Compare November 16, 2020 11:59
shogo82148 added a commit to shogo82148/fluent-bit-docs that referenced this pull request Nov 16, 2020
shogo82148 added a commit to shogo82148/fluent-bit-docs that referenced this pull request Nov 16, 2020
@shogo82148
Copy link
Contributor Author

Thank you for your review!
I fixed them, and created a new pull request on fluent-bit-docs fluent/fluent-bit-docs#419

@@ -1058,7 +1142,8 @@ int create_log_group(struct flb_cloudwatch *ctx)
ctx->group_created = FLB_TRUE;
flb_sds_destroy(body);
flb_http_client_destroy(c);
return 0;
int ret = set_log_group_retention(ctx);
Copy link
Contributor

Choose a reason for hiding this comment

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

always declare variables at the top of the function, per the style guide: https://github.com/fluent/fluent-bit/blob/master/CONTRIBUTING.md#variable-definitions

@PettitWesley
Copy link
Contributor

One new comment... then I think this is ready

@PettitWesley
Copy link
Contributor

Hey, actually, thinking about this some more, can you modify the code so that the retention policy is set even if the log group already exists.

Right now you only set the retention policy if the CreateLogGroup API responds with 200 success. You can also set the retention policy if it responds that the group already exists (which is a few lines down in the create group function)

This has been requested: aws/amazon-cloudwatch-logs-for-fluent-bit#121

@shogo82148 shogo82148 force-pushed the introduce-log-retention-days branch from 08e1850 to 5fe54f3 Compare November 23, 2020 07:33
@shogo82148
Copy link
Contributor Author

Sorry for my late response.
I fixed variable declaration #2739 (comment) and set the retention policy of the group already exists.

Copy link
Contributor

@PettitWesley PettitWesley left a comment

Choose a reason for hiding this comment

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

Thanks!

@PettitWesley PettitWesley merged commit 69f66c2 into fluent:master Nov 24, 2020
@shogo82148 shogo82148 deleted the introduce-log-retention-days branch February 18, 2021 02:43
shogo82148 added a commit to shogo82148/fluent-bit-docs that referenced this pull request Feb 18, 2021
shogo82148 added a commit to shogo82148/fluent-bit-docs that referenced this pull request Feb 18, 2021
edsiper pushed a commit to fluent/fluent-bit-docs that referenced this pull request Feb 18, 2021
@shogo82148
Copy link
Contributor Author

#2691 is not stale, but done.
Can someone close it? I have no permission to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AWS Issues with AWS plugins or experienced by users running on AWS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants