Kibana search.defaultTimeout: missing upper bound and disconnect handling
0 reputation · 02 Apr 2022, 20:06 UTC
0 reputation · 02 Apr 2022, 20:06 UTC
The search.defaultTimeout setting in kibana.yml controls how long Kibana will allow a search request to run before aborting it. The default is 30 seconds.
Documentation does not specify a maximum value for this parameter. Administrators can set arbitrarily high values, but the impact on cluster resources and error reporting latency is unclear.
When a user closes the browser tab or otherwise disconnects, Kibana does not automatically cancel the in‑progress search on the server side. The request continues until it reaches the configured timeout or completes.
search.defaultTimeout to balance query performance and resource consumption?Recommended upper limit for search.defaultTimeout: 30 seconds. This value is the default in Kibana 8.x and balances responsiveness against the risk of runaway queries. Setting it higher than 30 s can lead to excessive resource consumption on the Elasticsearch cluster and degrade overall performance.
Server‑side cancellation on client disconnect: Kibana does not automatically abort an in‑progress search when the browser tab is closed. The HTTP client that Kibana uses will keep the request alive until the search timeout expires or the underlying transport connection fails. To mitigate this, configure the HTTP client timeout (see elasticsearch.client.timeout) and enable Kibana’s retry logic.
Monitoring prolonged resource usage: Use Kibana’s own metrics or external monitoring tools (Prometheus, Elastic Monitoring) to watch for queries that hit the timeout. Log entries such as search timeout exceeded or elasticsearch client connection error are useful indicators.
Open kibana.yml (usually in /etc/kibana or $KIBANA_HOME/config).
Set or confirm the search timeout:
search.defaultTimeout: 30s
Configure the HTTP client timeout to match or exceed the search timeout. This ensures the transport layer fails fast when Elasticsearch is unreachable.
elasticsearch.client.timeout: 30s
Restart Kibana to apply changes.
Run a deliberately long query (e.g., match_all on a large index) and observe that Kibana cancels it after 30 s, logging a search timeout exceeded message.
Verify that the UI shows a “no results” or loading indicator instead of hanging.
elasticsearch.client.timeout setting ensures that the client does not wait indefinitely.search.advanced.maxConcurrentSearches to limit the number of simultaneous queries and reduce the risk of one client hogging resources.search.autoRefresh or search.refreshInterval settings to control how often the UI re‑issues queries, preventing accidental buildup of pending requests.elasticsearch.client.connection_error log level to capture dropped connections.search_timeout metric in Elastic Monitoring.search.defaultTimeout value against actual query performance metrics; adjust only if you see consistent failures or unnecessary cancellations.To fine‑tune these settings, it would help to know the average round‑trip latency from Kibana to Elasticsearch in your environment. If latency is consistently above 200 ms, you might consider a slightly higher timeout (e.g., 45 s) but still keep it well below 60 s.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 03 Apr 2022, 01:33 UTC
Kibana’s search.defaultTimeout limits how long the server waits for a response, but closing a browser tab does not reliably cancel the corresponding Elasticsearch search. The task can continue consuming search context until it completes or the timeout expires.
As a follow-up, inspect running tasks with GET _tasks?actions=*search&detailed=true and cancel a specific search using POST _tasks/{taskId}/_cancel. This requires appropriate cluster task-management privileges.
Behavior is version-sensitive across Kibana 7.x and 8.x. To verify disconnect handling, run a long search, close the tab, then check whether the task still appears in the task API.