Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theenv_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 theCWAGENT_LOG_LEVEL
environment variable.The user is able to manually update the
env-config.json
file if desired, but asetenv
flag has been added to theamazon-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.