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

Change runtime log level #293

Merged
merged 1 commit into from
Oct 14, 2021
Merged

Conversation

jefchien
Copy link
Contributor

@jefchien jefchien commented Oct 12, 2021

Description of the issue

For this issue: #280

The CloudWatch agent uses the telegraf logger to manage its logging. Currently, to change the log level, the agent configuration file needs to be updated to include debug: true in the agent section and the process needs to be restarted for the change to take effect.

Description of changes

Added a goroutine created in the reload_loop that will check the env_config.json file every 30 seconds to see if it has been changed. If the file has been changed, it will re-read the file and update the known environment variables. Normally, this is only done once on start up. It then tries to set the log level to the CWAGENT_LOG_LEVEL environment variable.

The user is able to manually update the env-config.json file if desired, but a setenv flag has been added to the amazon-cloudwatch-agent binary that will update the log level in the file. This can be accessed by running:

on linux: sudo /opt/aws/amazon-cloudwatch/bin/amazon-cloudwatch-agent-ctl -a set-log-level -l DEBUG
or
on windows: & $Env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -a set-log-level -l DEBUG

Note: If a user has debug:true present in their configuration file, CWAGENT_LOG_LEVEL will be set to "DEBUG" after translation of the configuration file has completed.

License

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

Tests

Tested on linux and windows ec2 instances.

…ing runtime.

Updated amazon-cloudwatch-agent-ctl with action to set log level.
@jefchien jefchien added this to the 1.247350.0 milestone Oct 12, 2021
Copy link
Contributor

@SaxyPandaBear SaxyPandaBear left a comment

Choose a reason for hiding this comment

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

LGTM

@jefchien jefchien linked an issue Oct 13, 2021 that may be closed by this pull request
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.

Change runtime log level
3 participants