mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
Merge pull request #58981 from azat/prom-handler
Fix timeout for prometheus exporter for HTTP/1.1 (due to keep-alive)
This commit is contained in:
commit
587295aca1
@ -19,6 +19,13 @@ void WriteBufferFromHTTPServerResponse::startSendHeaders()
|
||||
|
||||
if (response.getChunkedTransferEncoding())
|
||||
setChunked();
|
||||
else if (response.getContentLength() == Poco::Net::HTTPMessage::UNKNOWN_CONTENT_LENGTH)
|
||||
{
|
||||
/// In case there is no Content-Length we cannot use keep-alive,
|
||||
/// since there is no way to know when the server send all the
|
||||
/// data, so "Connection: close" should be sent.
|
||||
response.setKeepAlive(false);
|
||||
}
|
||||
|
||||
if (add_cors_header)
|
||||
response.set("Access-Control-Allow-Origin", "*");
|
||||
|
@ -23,6 +23,10 @@ void PrometheusRequestHandler::handleRequest(HTTPServerRequest & request, HTTPSe
|
||||
const auto & config = server.config();
|
||||
unsigned keep_alive_timeout = config.getUInt("keep_alive_timeout", DEFAULT_HTTP_KEEP_ALIVE_TIMEOUT);
|
||||
|
||||
/// In order to make keep-alive works.
|
||||
if (request.getVersion() == HTTPServerRequest::HTTP_1_1)
|
||||
response.setChunkedTransferEncoding(true);
|
||||
|
||||
setResponseDefaultHeaders(response, keep_alive_timeout);
|
||||
|
||||
response.setContentType("text/plain; version=0.0.4; charset=UTF-8");
|
||||
|
@ -40,6 +40,8 @@ def get_and_check_metrics(retries):
|
||||
response = requests.get(
|
||||
"http://{host}:{port}/metrics".format(host=node.ip_address, port=8001),
|
||||
allow_redirects=False,
|
||||
# less then default keep-alive timeout (10 seconds)
|
||||
timeout=5,
|
||||
)
|
||||
|
||||
if response.status_code != 200:
|
||||
|
Loading…
Reference in New Issue
Block a user