mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
Fix timeout for prometheus exporter for HTTP/1.1 (due to keep-alive)
Before: $ time curl -s --http1.1 127.1:9363/metrics > /dev/null real 0m10.018s # default keep_alive_timeout is 10 seconds user 0m0.005s sys 0m0.001s After $ time curl -s --http1.1 127.1:9363/metrics > /dev/null real 0m0.008s user 0m0.006s sys 0m0.000s And if you will look at the test_prometheus_endpoint, you will see that it takes > 30 seconds (it obtains metrics 3 times), after this patch it should be finished more or less instantly. Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
90057c6f39
commit
38ad4ef493
@ -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