Reputation: 3176
I am trying to tune the log levels of the various loggers in the Cloudwatch Logs Agent, and according to the official AWS reference docs, it states that I should be able to add the following to /var/awslogs/etc/awslogs.conf, in order to achieve that:
[loggers]
keys=root,cwlogs,reader,publisher
[handlers]
keys=consoleHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=INFO
handlers=consoleHandler
[logger_cwlogs]
level=INFO
handlers=consoleHandler
qualname=cwlogs.push
propagate=0
[logger_reader]
level=WARNING
handlers=consoleHandler
qualname=cwlogs.push.reader
propagate=0
[logger_publisher]
level=WARNING
handlers=consoleHandler
qualname=cwlogs.push.publisher
propagate=0
[handler_consoleHandler]
class=logging.StreamHandler
level=INFO
formatter=simpleFormatter
args=(sys.stderr,)
[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(process)d - %(threadName)s - %(message)s
When I do add it, logs forwarding stops and I see a relevant entry in /var/log/awslogs.log
:
No option 'file' in section: 'loggers'
Removing the whole section resumes logging, but - obviously - no log levels have been tuned.
Any ideas what I might be doing wrong?
Upvotes: 3
Views: 1587
Reputation: 1373
We had the same issue. In our case the root of the issue was that we put logging.conf file into /etc/awslogs/config
but instead you have to put it into /etc/awslogs
.
Your solution with file in loggers section didn't work for us we got new error
"No option 'log_group_name' in section: 'loggers'"
Our main awslogs file looks like
$ cat /etc/awslogs/awslogs.conf
[general]
state_file = /var/lib/awslogs/agent-state
logging_config_file = /etc/awslogs/logging.conf
use_gzip_http_content_encoding = true
logging.conf looks like
$ cat /etc/awslogs/logging.conf
[loggers]
keys=root,cwlogs,reader,publisher
[handlers]
keys=consoleHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=INFO
handlers=consoleHandler
[logger_cwlogs]
level=INFO
handlers=consoleHandler
qualname=cwlogs.push
propagate=0
[logger_reader]
level=ERROR
handlers=consoleHandler
qualname=cwlogs.push.reader
propagate=0
[logger_publisher]
level=ERROR
handlers=consoleHandler
qualname=cwlogs.push.publisher
propagate=0
[handler_consoleHandler]
class=logging.StreamHandler
level=INFO
formatter=simpleFormatter
args=(sys.stderr,)
[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(process)d - %(threadName)s - %(message)s
At the moment we use
$ rpm -qa | grep awslogs
awslogs-1.1.2-1.10.amzn1.noarch
Upvotes: 1
Reputation: 1302
Do not add these options to awslogs.conf
. Add them to a separate file that you then specify via the logging_config_file
key in awslogs.conf
:
/etc/awslogs/awslogs.conf
[general]
state_file = /var/lib/awslogs/agent-state
logging_config_file = /etc/awslogs/logging.conf
use_gzip_http_content_encoding = false
...
/etc/awslogs/logging.conf
[loggers]
keys=root,cwlogs,reader,publisher
file=/tmp/test
[handlers]
keys=consoleHandler
[formatters]
keys=simpleFormatter
[logger_root]
level=INFO
handlers=consoleHandler
[logger_cwlogs]
level=INFO
handlers=consoleHandler
qualname=cwlogs.push
propagate=0
[logger_reader]
level=WARNING
handlers=consoleHandler
qualname=cwlogs.push.reader
propagate=0
[logger_publisher]
level=WARNING
handlers=consoleHandler
qualname=cwlogs.push.publisher
propagate=0
[handler_consoleHandler]
class=logging.StreamHandler
level=INFO
formatter=simpleFormatter
args=(sys.stderr,)
[formatter_simpleFormatter]
format=%(asctime)s - %(name)s - %(levelname)s - %(process)d - %(threadName)s - %(message)s
Upvotes: 4