Package org.apache.hadoop.yarn.util
Class Log4jWarningErrorMetricsAppender
java.lang.Object
org.apache.log4j.AppenderSkeleton
org.apache.hadoop.yarn.util.Log4jWarningErrorMetricsAppender
- All Implemented Interfaces:
org.apache.log4j.Appender,org.apache.log4j.spi.OptionHandler
@Private
@Unstable
public class Log4jWarningErrorMetricsAppender
extends org.apache.log4j.AppenderSkeleton
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class org.apache.log4j.AppenderSkeleton
closed, errorHandler, headFilter, layout, name, tailFilter, threshold -
Constructor Summary
ConstructorsConstructorDescriptionCreate an appender to keep track of the errors and warnings logged by the system.Log4jWarningErrorMetricsAppender(int cleanupIntervalSeconds, long messageAgeLimitSeconds, int maxUniqueMessages) Create an appender to keep track of the errors and warnings logged by the system. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidappend(org.apache.log4j.spi.LoggingEvent event) voidclose()longgetErrorCounts(List<Long> cutoffs) Get the counts of errors in the time periods provided.getErrorMessagesAndCounts(List<Long> cutoffs) Get the errors and the number of occurrences for each of the errors for the time cutoffs provided.intlonggetWarningCounts(List<Long> cutoffs) Get the counts of warnings in the time periods provided.getWarningMessagesAndCounts(List<Long> cutoffs) Get the warning and the number of occurrences for each of the warnings for the time cutoffs provided.booleanvoidsetCleanupInterval(long cleanupInterval) voidsetMaxUniqueMessages(int maxUniqueMessages) voidsetMessageAgeLimitSeconds(long messageAgeLimitSeconds) Methods inherited from class org.apache.log4j.AppenderSkeleton
activateOptions, addFilter, clearFilters, doAppend, finalize, getErrorHandler, getFilter, getFirstFilter, getLayout, getName, getThreshold, isAsSevereAsThreshold, setErrorHandler, setLayout, setName, setThreshold
-
Field Details
-
LOG_METRICS_APPENDER
- See Also:
-
-
Constructor Details
-
Log4jWarningErrorMetricsAppender
public Log4jWarningErrorMetricsAppender()Create an appender to keep track of the errors and warnings logged by the system. It will keep purge messages older than 2 days. It will store upto the last 500 unique errors and the last 500 unique warnings. The thread to purge message will run every 5 minutes, unless the 500 message limit is hit earlier. -
Log4jWarningErrorMetricsAppender
public Log4jWarningErrorMetricsAppender(int cleanupIntervalSeconds, long messageAgeLimitSeconds, int maxUniqueMessages) Create an appender to keep track of the errors and warnings logged by the system.- Parameters:
cleanupIntervalSeconds- the interval at which old messages are purged to prevent the message stores from growing unboundedmessageAgeLimitSeconds- the maximum age of a message in seconds before it is purged from the storemaxUniqueMessages- the maximum number of unique messages of each type we keep before we start purging
-
-
Method Details
-
append
protected void append(org.apache.log4j.spi.LoggingEvent event) - Specified by:
appendin classorg.apache.log4j.AppenderSkeleton
-
close
public void close() -
requiresLayout
public boolean requiresLayout() -
getErrorCounts
Get the counts of errors in the time periods provided. Note that the counts provided by this function may differ from the ones provided by getErrorMessagesAndCounts since the message store is purged at regular intervals to prevent it from growing without bounds, while the store for the counts is purged less frequently.- Parameters:
cutoffs- list of timestamp cutoffs(in seconds) for which the counts are desired- Returns:
- list of error counts in the time periods corresponding to cutoffs
-
getWarningCounts
Get the counts of warnings in the time periods provided. Note that the counts provided by this function may differ from the ones provided by getWarningMessagesAndCounts since the message store is purged at regular intervals to prevent it from growing without bounds, while the store for the counts is purged less frequently.- Parameters:
cutoffs- list of timestamp cutoffs(in seconds) for which the counts are desired- Returns:
- list of warning counts in the time periods corresponding to cutoffs
-
getErrorMessagesAndCounts
public List<Map<String,Log4jWarningErrorMetricsAppender.Element>> getErrorMessagesAndCounts(List<Long> cutoffs) Get the errors and the number of occurrences for each of the errors for the time cutoffs provided. Note that the counts provided by this function may differ from the ones provided by getErrorCounts since the message store is purged at regular intervals to prevent it from growing without bounds, while the store for the counts is purged less frequently.- Parameters:
cutoffs- list of timestamp cutoffs(in seconds) for which the counts are desired- Returns:
- list of maps corresponding for each cutoff provided; each map contains the error and the number of times the error occurred in the time period
-
getWarningMessagesAndCounts
public List<Map<String,Log4jWarningErrorMetricsAppender.Element>> getWarningMessagesAndCounts(List<Long> cutoffs) Get the warning and the number of occurrences for each of the warnings for the time cutoffs provided. Note that the counts provided by this function may differ from the ones provided by getWarningCounts since the message store is purged at regular intervals to prevent it from growing without bounds, while the store for the counts is purged less frequently.- Parameters:
cutoffs- list of timestamp cutoffs(in seconds) for which the counts are desired- Returns:
- list of maps corresponding for each cutoff provided; each map contains the warning and the number of times the error occurred in the time period
-
getCleanupInterval
public long getCleanupInterval() -
setCleanupInterval
public void setCleanupInterval(long cleanupInterval) -
getMessageAgeLimitSeconds
public long getMessageAgeLimitSeconds() -
setMessageAgeLimitSeconds
public void setMessageAgeLimitSeconds(long messageAgeLimitSeconds) -
getMaxUniqueMessages
public int getMaxUniqueMessages() -
setMaxUniqueMessages
public void setMaxUniqueMessages(int maxUniqueMessages) -
findAppender
-