Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Ambari Metrics Collector Logging

Highlighted

Ambari Metrics Collector Logging

New Contributor

would like to know how to safely configure rotation and deletion of metrics collector log

did I miss it somewhere in documentation?

3 REPLIES 3

Re: Ambari Metrics Collector Logging

Super Mentor

@Julie Lin

In Ambari UI you should see that AMS has already log rotation enabled.

Ambari UI --> Ambari Metrics --> Configs --> Advanced ams-log4j

As following:

ams.log.dir=.
ams.log.file=ambari-metrics-collector.log

# Root logger option
log4j.rootLogger=INFO,file

# Direct log messages to a log file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=${ams.log.dir}/${ams.log.file}
log4j.appender.file.MaxFileSize=80MB
log4j.appender.file.MaxBackupIndex=60
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %p %c: %m%n

.

The following properties tells when the log rotation should be triggered.

log4j.appender.file.MaxFileSize=80MB
log4j.appender.file.MaxBackupIndex=60

.

Re: Ambari Metrics Collector Logging

New Contributor

thank you so much Jay SenSharma! this helps. I assume we can configure the log4j to also do compression?

Re: Ambari Metrics Collector Logging

Super Mentor

@Julie Lin

Yes, we can achieve the log4j based compression as well.

Sometime back i have written an article for the same using "apache-log4j-extras" you can find the instructions here: https://community.hortonworks.com/articles/50058/using-log4j-extras-how-to-rotate-as-well-as-zip-th....

Example:

#### New Appender to Zip the Log Files Based on Daily Rotation
log4j.appender.ZIPRFA=org.apache.log4j.rolling.RollingFileAppender
log4j.appender.ZIPRFA.File=${ams.log.dir}/${ams.log.file}
log4j.appender.ZIPRFA.layout=org.apache.log4j.PatternLayout
log4j.appender.ZIPRFA.layout.ConversionPattern=%d{ISO8601} %p %c: %m%
log4j.appender.ZIPRFA.rollingPolicy=org.apache.log4j.rolling.TimeBasedRollingPolicy
log4j.appender.ZIPRFA.rollingPolicy.ActiveFileName=${ams.log.dir}/${ams.log.file}
log4j.appender.ZIPRFA.rollingPolicy.FileNamePattern=${ams.log.dir}/${ams.log.file}-.%d{yyyyMMdd}.log.gz

.

Don't have an account?
Coming from Hortonworks? Activate your account here