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

Add support for dynamic log groups using templating variables. #81

Merged
merged 21 commits into from
Sep 14, 2020
Merged

Add support for dynamic log groups using templating variables. #81

merged 21 commits into from
Sep 14, 2020

Conversation

davidnewhall
Copy link
Contributor

@davidnewhall davidnewhall commented Aug 20, 2020

Closes #46, closes #6, closes #24, closes #49.

Description of changes:

This builds on #78 (more commits to that branch), and can be merged after (making this diff smaller), or in leu of #78.

I create a new struct type called Event that carries the Event payload and metadata through the entire request process. Previously the code was passing around the log stream name, and now it passes around the Event which contains the stream name, group name, tag and log record. This makes the data easier to reason about.

  • I adapted the same code that created a template from the log stream name to the log group.
  • Added a new groups map-tracker to the OutputPlugin struct. Gets added to when new groups are created.
  • Added the log group name to the logStream struct, so each log stream has a pinned unique group.
  • Auto create group was removed; groups are now auto-created if they don't exist.
  • The group name now supports template variables, explained in the README.

This config:

    log_group_name      /ecs/twitch-fluentbit/$(tag)/$(host)
    log_stream_name     $(tag[0]).$(ident)

Turns into this (groups):

Screen Shot 2020-08-19 at 5 34 47 PM
Screen Shot 2020-08-19 at 5 34 35 PM

Streams Created:
Screen Shot 2020-08-19 at 5 48 05 PM

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@davidnewhall davidnewhall requested a review from a team as a code owner August 20, 2020 00:58
@davidnewhall davidnewhall changed the title Add support for dynamic log groups. Add support for dynamic log groups using templating variables. Aug 20, 2020
@cwyl02
Copy link

cwyl02 commented Aug 24, 2020

hello when will this get review/merged? This is a feature we are looking for!

@hossain-rayhan
Copy link
Contributor

Hey @cwyl02 , sorry its taking longer but we are on it.

README.md Outdated
* `log_group_name`: The name of the CloudWatch Log Group that you want log records sent to.
* `log_stream_name`: The name of the CloudWatch Log Stream that you want log records sent to.
* `log_stream_prefix`: Prefix for the Log Stream name. The tag is appended to the prefix to construct the full log stream name. Not compatible with the `log_stream_name` option.
* `log_group_name`: The name of the CloudWatch Log Group that you want log records sent to. This value allows a template in the form of `${variable}`. See `log_stream_name` description for more. The app will attempt to create missing log groups, and will throw an error if it does not have access.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be $(variable)? From #78 conversation, we planned to replace ${ } with $( ). Am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was waiting for your team to provide feedback on the chosen variable identifiers. If y'all are good with #() I'll go ahead and fix the doc. Is there any additional feedback before making a final commit?

Copy link
Contributor

Choose a reason for hiding this comment

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

We voted and we prefer $()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, I'll switch it up and test before committing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a commit changes the identifiers. Updated the readme. Made some comments better. Fixed a few log lines and added a couple debug lines. If you guys don't mind I'll follow-up with a clean-up PR (no features).

README.md Outdated Show resolved Hide resolved
cloudwatch/cloudwatch.go Show resolved Hide resolved
@PettitWesley PettitWesley merged commit 9793272 into aws:mainline Sep 14, 2020
@davidnewhall davidnewhall deleted the dn2_dynamic_log_groups branch September 24, 2020 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamic Coudwatch Log Groups Intrepolation of the log_group
4 participants