Context deadline exceeded error lacks accessible details in Prometheus UI
0 reputation · 30 Apr 2023, 08:37 UTC
0 reputation · 30 Apr 2023, 08:37 UTC
Goal: ensure that when a PromQL query exceeds the configured timeout, the error presented in the web UI conveys sufficient detail and is announced properly to assistive technologies, enabling users to understand the cause and adjust their workflow.
Currently the UI shows a generic 'Query failed' banner without ARIA labels or specific message, while the backend logs the 'context deadline exceeded' error. The timeout is set only via the global --query.timeout flag, with no per‑user or per‑request override, a design decision still under discussion. This leaves users on slow connections or relying on screen readers without clear guidance.
Should the UI display the underlying error string or a more descriptive message? Should ARIA live regions be added to announce the failure? Is there value in exposing a per‑request timeout mechanism via query parameters or HTTP headers?
When a PromQL query exceeds --query.timeout, Prometheus returns a context deadline exceeded error in the backend logs, but the web UI currently shows only a generic “Query failed” banner. To give users—especially those relying on screen readers—a clear, accessible explanation, the UI should expose a sanitized, descriptive error message and use an ARIA live region so the failure is announced immediately.
context deadline exceeded when a query times out.role="alert" to the banner will cause screen readers to announce the message as soon as it appears.The lack of detail stems from the UI’s design choice to keep error handling simple and avoid leaking internal error messages. However, for accessibility and usability, a more descriptive message—e.g., “Query timed out after 30 s. Consider simplifying the query or increasing the timeout”—provides actionable insight.
prometheus --version to confirm you’re on 2.46.x or later, where the UI source is web/ui.
/api/v1/query and confirm the JSON body contains errorType:"timeout" and error:"context deadline exceeded".
web/ui/src/components/QueryResultBanner.jsx, replace the static string with a conditional that shows:
{errorType === 'timeout' && 'Query timed out after 30 s. Try a simpler query or increase the timeout.'}
<div role="alert"> so screen readers announce it immediately.
make build and restart Prometheus.
Prometheus currently does not support a per‑request timeout via query parameters or headers. Implementing such a feature would require changes to the HTTP handler to read a custom header (e.g., X-Prometheus-Timeout) and wrap the query execution in a context with that deadline. This is a non‑trivial change and is not recommended for quick fixes. Instead, users can:
--query.timeout flag if many queries need more time.
Could you confirm which Prometheus release you’re running? Knowing the exact version will help verify whether the UI already includes any of the suggested improvements in newer releases.
Use comments to ask for clarification. Post a solution as an answer.
32,775 reputation · 30 Apr 2023, 17:10 UTC
To implement a descriptive error message without leaking sensitive backend details, the UI should map the specific errorType: "timeout" found in the API response to a predefined user-facing string. This prevents the risk of piping raw Go error strings directly to the frontend.
When verifying the fix, it is important to distinguish between a backend timeout (triggered by --query.timeout) and a gateway timeout (e.g., a 504 from an Nginx reverse proxy). A gateway timeout often returns an HTML page rather than the Prometheus JSON error payload, which would bypass the errorType logic and likely trigger the generic "Query failed" banner again.
Ensuring the UI handles both JSON error payloads and non-JSON HTTP error codes will provide a more robust accessibility experience for users on unstable connections.