{"record":{"id":"aeba4fc98c7b52ba","repo":"apache/druid","slug":"failed-to-parse-metric-configuration","errorCode":null,"errorMessage":"Failed to parse metric configuration","messagePattern":"Failed to parse metric configuration","errorType":"validation","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"extensions-contrib/prometheus-emitter/src/main/java/org/apache/druid/emitter/prometheus/Metrics.java","lineNumber":149,"sourceCode":"  }\n\n  private Map<String, Metric> readConfig(String path)\n  {\n    try {\n      InputStream is;\n      if (Strings.isNullOrEmpty(path)) {\n        log.info(\"Using default metric configuration\");\n        is = this.getClass().getClassLoader().getResourceAsStream(\"defaultMetrics.json\");\n      } else {\n        log.info(\"Using metric configuration at [%s]\", path);\n        is = new FileInputStream(new File(path));\n      }\n      return mapper.readerFor(new TypeReference<Map<String, Metric>>()\n      {\n      }).readValue(is);\n    }\n    catch (IOException e) {\n      throw new ISE(e, \"Failed to parse metric configuration\");\n    }\n  }\n\n  public Map<String, DimensionsAndCollector> getRegisteredMetrics()\n  {\n    return registeredMetrics;\n  }\n\n  public static class Metric\n  {\n    public final SortedSet<String> dimensions;\n    public final Type type;\n    public final String help;\n    public final double conversionFactor;\n    public final double[] histogramBuckets;\n\n    @JsonCreator\n    public Metric(","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/apache/druid/blob/9b90983fd291f26935af934383ce360473179e4d/extensions-contrib/prometheus-emitter/src/main/java/org/apache/druid/emitter/prometheus/Metrics.java#L131-L167","documentation":"Prometheus emitter's Metrics.readConfig deserializes the metric definitions file into Map<String, Metric>. If the file is not parseable into that shape (invalid YAML/JSON or wrong structure), it throws ISE with 'Failed to parse metric configuration' during emitter setup.","triggerScenarios":"The prometheus emitter's metrics config file (druid.emitter.prometheus.metricDefinitionsPath or bundled default) contains malformed YAML/JSON or entries that don't match the expected Metric schema; read when the emitter is created.","commonSituations":"Custom metric definition files with YAML syntax errors, wrong field names in Metric entries, top-level list instead of map, or an empty/corrupt file.","solutions":["Validate the metrics YAML/JSON parses and maps metric names to Metric objects with the expected fields (type, help, dimensions, etc.)","Fix YAML indentation/typos and ensure each entry includes required Metric properties","Compare against the bundled default metrics definition file for the correct schema"],"exampleFix":"// before (bad YAML)\ndruid/request/converted/time:\n  type: TIMER\n  help: missing colon here\n// after\ndruid/request/converted/time:\n  type: TIMER\n  help: Request conversion time","handlingStrategy":"validation","validationCode":"Object cfg = new Yaml().load(metricsFile);\nif (!(cfg instanceof Map)) throw new IllegalArgumentException(\"prometheus metrics config must be a map of metric name -> Metric\");\n((Map<?, ?>) cfg).forEach((k, v) -> { if (!(v instanceof Map)) throw new IllegalArgumentException(\"bad entry: \" + k); });","typeGuard":null,"tryCatchPattern":"try { Metrics.fromConfig(mapper, is); } catch (IllegalStateException e) { if (e.getMessage().contains(\"parse metric configuration\")) { log.error(\"Check metricDefinitionsPath file: {}\", e.getCause()); } }","preventionTips":["Validate custom metric definition files with a YAML parser in CI","Match the bundled default metrics file schema exactly (type, help, dimensions)","After editing, diff your file against the upstream default to catch structural drift"],"tags":["java","yaml","emitter","prometheus"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"9b90983fd291f26935af934383ce360473179e4d","analyzedAt":"2026-09-07T13:32:30.957Z","contentChangedAt":"2026-09-07T13:32:30.957Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}