apache/hadoop · error · MetricsConfigException

Error stringify config

Error message

Error stringify config

What it means

MetricsSystemImpl.currentConfig() copies the active metrics2 configuration into a PropertiesConfiguration and writes it to a StringWriter to produce a string dump. Any failure during the write is wrapped in MetricsConfigException('Error stringify config', e) with the original cause attached, so the in-memory config could not be serialized.

Source

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

      sa.startMBeans();
    }
  }

  @Override
  public synchronized void stopMetricsMBeans() {
    for (MetricsSourceAdapter sa : sources.values()) {
      sa.stopMBeans();
    }
  }

  @Override
  public synchronized String currentConfig() {
    PropertiesConfiguration saver = new PropertiesConfiguration();
    StringWriter writer = new StringWriter();
    saver.copy(config);
    try { saver.write(writer); }
    catch (Exception e) {
      throw new MetricsConfigException("Error stringify config", e);
    }
    return writer.toString();
  }

  private synchronized void startTimer() {
    if (timer != null) {
      LOG.warn(prefix +" metrics system timer already started!");
      return;
    }
    logicalTime = 0;
    long millis = period;
    timer = new Timer("Timer for '"+ prefix +"' metrics system", true);
    timer.scheduleAtFixedRate(new TimerTask() {
          @Override
          public void run() {
            try {
              onTimerEvent();
            } catch (Exception e) {

View on GitHub (pinned to 2add963021)

Solutions

  1. Inspect MetricsConfigException.getCause() to see exactly what PropertiesConfiguration failed on
  2. Audit hadoop-metrics2.properties and any programmatic config for non-string property values
  3. Simplify the offending property to a plain string value or remove it

Example fix

// before
String dump = ((MetricsSystemImpl) ms).currentConfig();  // throws MetricsConfigException

// after
try {
  String dump = ((MetricsSystemImpl) ms).currentConfig();
} catch (MetricsConfigException e) {
  LOG.error("Cannot stringify metrics config: " + e.getCause(), e);
}
Defensive patterns

Strategy: try-catch

Try / catch

try {
  String cfg = metricsSystem.currentConfig();
} catch (MetricsConfigException e) {
  LOG.error("metrics config dump failed: " + e.getCause(), e);
  // proceed without the dump; do not fail the application for a diagnostics call
}

Prevention

When it happens

Trigger: Calling currentConfig() (directly or via tooling that dumps metrics config) when the loaded configuration holds values PropertiesConfiguration cannot render — e.g., non-scalar objects injected programmatically by custom metrics plugins — or when the writer itself throws.

Common situations: Custom MetricsSystem configuration assembled in code rather than from hadoop-metrics2.properties; plugins that mutate the config object; typically noticed when dumping config for debugging.

Related errors


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