apache/seatunnel · error · HttpConnectorException

HttpConnectorErrorCode.REQUEST_FAILED

HttpConnectorErrorCode.REQUEST_FAILED

Error message

http client execute exception, http response status code:[%s], content:[%s]

What it means

The Prometheus source reader's pollAndCollectData executes an HTTP request against the Prometheus server and throws HttpConnectorException(REQUEST_FAILED) whenever the response status code is not a success. It means the HTTP client executed fine but the Prometheus API rejected the request (auth failure, bad query, server error, etc.). The message includes the status code and response body for diagnosis.

Source

Thrown at seatunnel-connectors-v2/connector-prometheus/src/main/java/org/apache/seatunnel/connectors/seatunnel/prometheus/source/PrometheusSourceReader.java:222

                    String lineStr;
                    while ((lineStr = bufferedReader.readLine()) != null) {
                        collect(output, lineStr);
                    }
                } else {
                    collect(output, content);
                }
            }
            log.debug(
                    "http client execute success request param:[{}], http response status code:[{}], content:[{}]",
                    httpParameter.getParams(),
                    response.getCode(),
                    response.getContent());
        } else {
            String msg =
                    String.format(
                            "http client execute exception, http response status code:[%s], content:[%s]",
                            response.getCode(), response.getContent());
            throw new HttpConnectorException(HttpConnectorErrorCode.REQUEST_FAILED, msg);
        }
    }
}

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Read the status code and content in the message to identify the cause (4xx = request problem, 5xx = server problem).
  2. Verify the prometheus URL/endpoint and query parameters in the source config are correct and reachable (curl the same URL).
  3. Check credentials/proxy configuration if the status is 401/403.
  4. Retry later or scale Prometheus if the status is 5xx/503 (server-side overload or restart).

Example fix

// before
url = "http://prometheus-wrong-host:9090/api/v1/query"
// after
url = "http://prometheus:9090/api/v1/query"  // verified with curl returning 200
Defensive patterns

Strategy: try-catch

Validate before calling

curl -s -o /dev/null -w '%{http_code}' 'http://prometheus:9090/api/v1/query?query=up'  # expect 200 before running the job

Try / catch

try { reader.pollNext(...) } catch (HttpConnectorException e) { LOG.error("Prometheus request failed: {} {}", e.getMessage(), e); /* inspect status code, backoff-retry or fail job */ }

Prevention

When it happens

Trigger: PrometheusSourceReader.pollAndCollectData (via internalPollNext) issues an HTTP query; the returned response code is a non-success status (e.g. 400 bad PromQL query, 401/403 bad credentials, 5xx server error).

Common situations: Wrong prometheus host/port in URL config; a malformed query producing 400; Prometheus behind a proxy returning 401/403; Prometheus overloaded or restarting returning 503; firewalls/ingress returning 404 for a wrong path prefix.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/6979988c74e45cf9. Report an issue: GitHub.