org.apache.hadoop.metrics2.MetricsSource@Private
public class TopMetrics
extends java.lang.Object
implements org.apache.hadoop.metrics2.MetricsSource
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
| Modifier and Type | Field | Description |
|---|---|---|
static org.slf4j.Logger |
LOG |
|
static java.lang.String |
TOPMETRICS_METRICS_SOURCE_NAME |
| Constructor | Description |
|---|---|
TopMetrics(org.apache.hadoop.conf.Configuration conf,
int[] reportingPeriods) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
getMetrics(org.apache.hadoop.metrics2.MetricsCollector collector,
boolean all) |
Flatten out the top window metrics into
MetricsRecords for consumption by
external metrics systems. |
java.util.List<RollingWindowManager.TopWindow> |
getTopWindows() |
Get a list of the current TopWindow statistics, one TopWindow per tracked
time interval.
|
void |
report(boolean succeeded,
java.lang.String userName,
java.net.InetAddress addr,
java.lang.String cmd,
java.lang.String src,
java.lang.String dst,
org.apache.hadoop.fs.FileStatus status) |
Pick the same information that DefaultAuditLogger does before writing to a
log file.
|
void |
report(long currTime,
java.lang.String userName,
java.lang.String cmd) |
|
void |
report(java.lang.String userName,
java.lang.String cmd) |
public static final org.slf4j.Logger LOG
public static final java.lang.String TOPMETRICS_METRICS_SOURCE_NAME
public TopMetrics(org.apache.hadoop.conf.Configuration conf,
int[] reportingPeriods)
public java.util.List<RollingWindowManager.TopWindow> getTopWindows()
public void report(boolean succeeded,
java.lang.String userName,
java.net.InetAddress addr,
java.lang.String cmd,
java.lang.String src,
java.lang.String dst,
org.apache.hadoop.fs.FileStatus status)
TopMetrics is charged with
data read back from log files instead of being invoked directly by the
FsNamesystemsucceeded - userName - addr - cmd - src - dst - status - public void report(java.lang.String userName,
java.lang.String cmd)
public void report(long currTime,
java.lang.String userName,
java.lang.String cmd)
public void getMetrics(org.apache.hadoop.metrics2.MetricsCollector collector,
boolean all)
MetricsRecords 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.getMetrics in interface org.apache.hadoop.metrics2.MetricsSourcecollector - all - Copyright © 2008–2025 Apache Software Foundation. All rights reserved.