{"record":{"id":"a32ad1e4ed9dedf3","repo":"apache/seatunnel","slug":"unsupported-metrics-format","errorCode":null,"errorMessage":"Unsupported metrics format","messagePattern":"Unsupported metrics format","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/MetricsServlet.java","lineNumber":54,"sourceCode":"\n    public MetricsServlet(NodeEngineImpl nodeEngine) {\n        super(nodeEngine);\n        nodeExtension = (NodeExtension) nodeEngine.getNode().getNodeExtension();\n    }\n\n    @Override\n    protected void doGet(HttpServletRequest req, HttpServletResponse resp)\n            throws ServletException, IOException {\n        String servletPath = req.getServletPath();\n        String contentType;\n        if (servletPath.endsWith(RestConstant.REST_URL_METRICS)) {\n            contentType = TextFormat.CONTENT_TYPE_004;\n        } else if (servletPath.endsWith(RestConstant.REST_URL_OPEN_METRICS)) {\n            contentType = TextFormat.CONTENT_TYPE_OPENMETRICS_100;\n        } else {\n            // should not happen, because the servlet is only registered for /metrics and\n            // /open-metrics\n            throw new IllegalArgumentException(\"Unsupported metrics format\");\n        }\n        try (StringWriter stringWriter = new StringWriter()) {\n            TextFormat.writeFormat(\n                    contentType, stringWriter, nodeExtension.getMetricFamilySamples());\n            write(resp, stringWriter.toString());\n        }\n    }\n}\n","sourceCodeStart":36,"sourceCodeEnd":63,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-engine/seatunnel-engine-server/src/main/java/org/apache/seatunnel/engine/server/rest/servlet/MetricsServlet.java#L36-L63","documentation":"MetricsServlet.doGet selects the Prometheus text format based on which registered path the request hit (/metrics -> 004 format, /open-metrics -> OpenMetrics 1.0.0). If the servlet path matches neither suffix it throws IllegalArgumentException; this is marked 'should not happen' because the servlet is only mapped for those two URLs.","triggerScenarios":"Request reaching MetricsServlet under a path that does not end with the configured REST_URL_METRICS or REST_URL_OPEN_METRICS suffixes — e.g. a custom servlet mapping change, path suffix stripped by a proxy, or a modified RestConstant.","commonSituations":"Operators remount the servlet on a new path without updating RestConstant; aggressive URL normalization strips trailing segments; misconfigured metrics scrape paths in Prometheus/Grafana agent configs.","solutions":["Scrape only the registered paths /metrics or /open-metrics","Fix the servlet registration/mapping so it matches the RestConstant URL suffixes","If a new path is added intentionally, add a corresponding content-type branch in doGet","Check that reverse proxies pass the full original path through"],"exampleFix":"// before (custom registration without suffix match)\ncontext.addServlet(new ServletHolder(metricsServlet), \"/prometheus\");\n// after\ncontext.addServlet(new ServletHolder(metricsServlet), \"/metrics\");\ncontext.addServlet(new ServletHolder(metricsServlet), \"/open-metrics\");","handlingStrategy":"validation","validationCode":"if (!url.endsWith(\"/metrics\") && !url.endsWith(\"/open-metrics\")) throw new IllegalArgumentException(\"scrape path must be /metrics or /open-metrics\");","typeGuard":"String contentTypeFor(String path) { return path.endsWith(\"/open-metrics\") ? TextFormat.CONTENT_TYPE_OPENMETRICS_100 : path.endsWith(\"/metrics\") ? TextFormat.CONTENT_TYPE_004 : null; }","tryCatchPattern":"try { text = scrapeMetrics(path); } catch (IllegalArgumentException e) { fixScrapeConfig(); }","preventionTips":["Configure Prometheus/Grafana to scrape exactly /metrics or /open-metrics","Do not remount the servlet on other paths without updating RestConstant","Disable path-stripping rewrites for the metrics route"],"tags":["rest","metrics","prometheus","unsupported-value"],"backgroundTag":"unsupported-operation","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}