{"record":{"id":"16d42aa63dab7b3b","repo":"apache/hadoop","slug":"not-found-16d42a","errorCode":null,"errorMessage":"{} not found","messagePattern":"(.+?) not found","errorType":"exception","errorClass":"AttributeNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java","lineNumber":111,"sourceCode":"    this(prefix, name, description, source, injectedTags,\n         conf.getFilter(RECORD_FILTER_KEY),\n         conf.getFilter(METRIC_FILTER_KEY),\n         period + 1, // hack to avoid most of the \"innocuous\" races.\n         conf.getBoolean(START_MBEANS_KEY, true));\n  }\n\n  void start() {\n    if (startMBeans) startMBeans();\n  }\n\n  @Override\n  public Object getAttribute(String attribute)\n      throws AttributeNotFoundException, MBeanException, ReflectionException {\n    updateJmxCache();\n    synchronized(this) {\n      Attribute a = attrCache.get(attribute);\n      if (a == null) {\n        throw new AttributeNotFoundException(attribute +\" not found\");\n      }\n      if (LOG.isDebugEnabled()) {\n        LOG.debug(attribute +\": \"+ a);\n      }\n      return a.getValue();\n    }\n  }\n\n  @Override\n  public void setAttribute(Attribute attribute)\n      throws AttributeNotFoundException, InvalidAttributeValueException,\n             MBeanException, ReflectionException {\n    throw new UnsupportedOperationException(\"Metrics are read-only.\");\n  }\n\n  @Override\n  public AttributeList getAttributes(String[] attributes) {\n    updateJmxCache();","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/metrics2/impl/MetricsSourceAdapter.java#L93-L129","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Enumerate the valid names with getMBeanInfo().getAttributes() on that bean and correct the queried name","Update the monitoring config to the metric names of the actually deployed Hadoop version","Catch AttributeNotFoundException in the poller and treat that single attribute as missing instead of failing the whole poll","If the metric should exist, wait one metrics period (cache TTL refresh) and re-query"],"exampleFix":"// before\nObject v = mbsc.getAttribute(objectName, \"NumOpenFilesTypo\");\n\n// after\nMBeanInfo info = mbsc.getMBeanInfo(objectName);\nboolean exists = Arrays.stream(info.getAttributes())\n    .anyMatch(a -> a.getName().equals(\"NumOpenFilesTypo\"));\nObject v = exists ? mbsc.getAttribute(objectName, \"NumOpenFilesTypo\") : null;","handlingStrategy":"try-catch","validationCode":"MBeanInfo info = mbsc.getMBeanInfo(objectName);\nSet<String> valid = Arrays.stream(info.getAttributes())\n    .map(MBeanFeatureInfo::getName).collect(Collectors.toSet());\nif (valid.contains(attrName)) {\n  Object v = mbsc.getAttribute(objectName, attrName);\n}","typeGuard":null,"tryCatchPattern":"try {\n  Object v = mbsc.getAttribute(objectName, attrName);\n} catch (AttributeNotFoundException e) {\n  // attribute absent in this source/version: log once and continue polling others\n}","preventionTips":["Derive attribute names dynamically from getMBeanInfo() instead of hard-coding them","Pin monitoring templates to the deployed Hadoop release and test them against that version","Treat single missing attributes as non-fatal in pollers so one rename cannot break monitoring"],"tags":["jmx","metrics2","hadoop","monitoring","attribute-not-found"],"backgroundTag":"jmx-attribute-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}