apache/hadoop · error · AttributeNotFoundException

{} not found

Error message

{} not found

What it means

Hadoop metrics2 exposes every MetricsSource as a JMX DynamicMBean via MetricsSourceAdapter. getAttribute(String) first refreshes a TTL-based JMX cache (updateJmxCache) and then looks the requested name up in attrCache; a name absent from the source's latest snapshot throws the standard JMX AttributeNotFoundException ('<name> not found'). It means the polled attribute name does not exist for this source, not that the bean itself is broken.

Source

Thrown at hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java:111

    this(prefix, name, description, source, injectedTags,
         conf.getFilter(RECORD_FILTER_KEY),
         conf.getFilter(METRIC_FILTER_KEY),
         period + 1, // hack to avoid most of the "innocuous" races.
         conf.getBoolean(START_MBEANS_KEY, true));
  }

  void start() {
    if (startMBeans) startMBeans();
  }

  @Override
  public Object getAttribute(String attribute)
      throws AttributeNotFoundException, MBeanException, ReflectionException {
    updateJmxCache();
    synchronized(this) {
      Attribute a = attrCache.get(attribute);
      if (a == null) {
        throw new AttributeNotFoundException(attribute +" not found");
      }
      if (LOG.isDebugEnabled()) {
        LOG.debug(attribute +": "+ a);
      }
      return a.getValue();
    }
  }

  @Override
  public void setAttribute(Attribute attribute)
      throws AttributeNotFoundException, InvalidAttributeValueException,
             MBeanException, ReflectionException {
    throw new UnsupportedOperationException("Metrics are read-only.");
  }

  @Override
  public AttributeList getAttributes(String[] attributes) {
    updateJmxCache();

View on GitHub (pinned to 2add963021)

Solutions

  1. Enumerate the valid names with getMBeanInfo().getAttributes() on that bean and correct the queried name
  2. Update the monitoring config to the metric names of the actually deployed Hadoop version
  3. Catch AttributeNotFoundException in the poller and treat that single attribute as missing instead of failing the whole poll
  4. If the metric should exist, wait one metrics period (cache TTL refresh) and re-query

Example fix

// before
Object v = mbsc.getAttribute(objectName, "NumOpenFilesTypo");

// after
MBeanInfo info = mbsc.getMBeanInfo(objectName);
boolean exists = Arrays.stream(info.getAttributes())
    .anyMatch(a -> a.getName().equals("NumOpenFilesTypo"));
Object v = exists ? mbsc.getAttribute(objectName, "NumOpenFilesTypo") : null;
Defensive patterns

Strategy: try-catch

Validate before calling

MBeanInfo info = mbsc.getMBeanInfo(objectName);
Set<String> valid = Arrays.stream(info.getAttributes())
    .map(MBeanFeatureInfo::getName).collect(Collectors.toSet());
if (valid.contains(attrName)) {
  Object v = mbsc.getAttribute(objectName, attrName);
}

Try / catch

try {
  Object v = mbsc.getAttribute(objectName, attrName);
} catch (AttributeNotFoundException e) {
  // attribute absent in this source/version: log once and continue polling others
}

Prevention

When it happens

Trigger: A JMX client (MBeanServerConnection.getAttribute/getAttributes, jconsole, check_jmx, Prometheus JMX exporter) requests an attribute that is not in attrCache: a typo, a name that only exists in another Hadoop version, a metric the source stopped publishing, or a query issued before the first snapshot populated the cache.

Common situations: Monitoring templates written against one Hadoop release and pointed at another (metric names drift across versions); polling a daemon right at startup before the first metrics cycle; tools that enumerate attributes once, then later request names that were removed.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/16d42aa63dab7b3b. Report an issue: GitHub.