Class TopMetrics
java.lang.Object
org.apache.hadoop.hdfs.server.namenode.top.metrics.TopMetrics
- All Implemented Interfaces:
org.apache.hadoop.metrics2.MetricsSource
The interface to the top metrics.
Metrics are collected by a custom audit logger, .hdfs.server.namenode.top.TopAuditLogger, which calls TopMetrics to
increment per-operation, per-user counts on every audit log call. These
counts are used to show the top users by NameNode operation as well as
across all operations.
TopMetrics maintains these counts for a configurable number of time intervals, e.g. 1min, 5min, 25min. Each interval is tracked by a RollingWindowManager.
These metrics are published as a JSON string via .hdfs.server .namenode.metrics.FSNamesystemMBean#getTopWindows. This is
done by calling .RollingWindowManager#snapshot on each RollingWindowManager.
Thread-safe: relies on thread-safety of RollingWindowManager
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTopMetrics(org.apache.hadoop.conf.Configuration conf, int[] reportingPeriods) -
Method Summary
Modifier and TypeMethodDescriptionvoidgetMetrics(org.apache.hadoop.metrics2.MetricsCollector collector, boolean all) Flatten out the top window metrics intoMetricsRecords for consumption by external metrics systems.Get a list of the current TopWindow statistics, one TopWindow per tracked time interval.voidreport(boolean succeeded, String userName, InetAddress addr, String cmd, String src, String dst, org.apache.hadoop.fs.FileStatus status) Pick the same information that DefaultAuditLogger does before writing to a log file.voidvoid
-
Field Details
-
LOG
public static final org.slf4j.Logger LOG -
TOPMETRICS_METRICS_SOURCE_NAME
- See Also:
-
-
Constructor Details
-
TopMetrics
public TopMetrics(org.apache.hadoop.conf.Configuration conf, int[] reportingPeriods)
-
-
Method Details
-
getTopWindows
Get a list of the current TopWindow statistics, one TopWindow per tracked time interval. -
report
public void report(boolean succeeded, String userName, InetAddress addr, String cmd, String src, String dst, org.apache.hadoop.fs.FileStatus status) Pick the same information that DefaultAuditLogger does before writing to a log file. This is to be consistent whenTopMetricsis charged with data read back from log files instead of being invoked directly by the FsNamesystem- Parameters:
succeeded-userName-addr-cmd-src-dst-status-
-
report
-
report
-
getMetrics
public void getMetrics(org.apache.hadoop.metrics2.MetricsCollector collector, boolean all) Flatten out the top window metrics intoMetricsRecords for consumption by external metrics systems. Each metrics record added corresponds to the reporting period a.k.a window length of the configured rolling windows.- Specified by:
getMetricsin interfaceorg.apache.hadoop.metrics2.MetricsSource- Parameters:
collector-all-
-