{"record":{"id":"67b68ecad3ada855","repo":"prestodb/presto","slug":"prometheus-unknown-error","errorCode":"PROMETHEUS_UNKNOWN_ERROR","errorMessage":"Error reading metrics","messagePattern":"Error reading metrics","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-prometheus/src/main/java/com/facebook/presto/plugin/prometheus/PrometheusClient.java","lineNumber":202,"sourceCode":"                }\n            }\n            else {\n                response = httpClient.newCall(requestBuilder.build()).execute();\n                if (response.isSuccessful() && response.body() != null) {\n                    return response.body().bytes();\n                }\n            }\n        }\n        catch (SSLHandshakeException e) {\n            throw new PrestoException(PROMETHEUS_SECURE_COMMUNICATION_ERROR, \"An SSL handshake error occurred while establishing a secure connection. Try the following measures to resolve the error:\\n\\n\" + \"- Upload a valid SSL certificate for authentication\\n- Verify the expiration status of the uploaded certificate.\\n- If you are connecting with SSL, enable SSL on both ends of the connection.\\n\", e);\n        }\n        catch (SSLPeerUnverifiedException e) {\n            throw new PrestoException(PROMETHEUS_SECURE_COMMUNICATION_ERROR, \"Peer verification failed. These measures might resolve the issue \\n\" +\n                    \"- Add correct Hostname in the SSL certificate's SAN list \\n\" +\n                    \"- The certificate chain might be incomplete. Check your SSL certificate\\n\", e);\n        }\n        catch (IOException e) {\n            throw new PrestoException(PROMETHEUS_UNKNOWN_ERROR, \"Error reading metrics\", e);\n        }\n        catch (NoSuchAlgorithmException e) {\n            throw new PrestoException(PROMETHEUS_SECURE_COMMUNICATION_ERROR, \"Requested cryptographic algorithm is not available\", e);\n        }\n        catch (KeyStoreException e) {\n            throw new PrestoException(PROMETHEUS_SECURE_COMMUNICATION_ERROR, \"Keystore operation error\", e);\n        }\n        catch (KeyManagementException e) {\n            throw new PrestoException(PROMETHEUS_SECURE_COMMUNICATION_ERROR, \"Key management operation error\", e);\n        }\n\n        throw new PrestoException(PROMETHEUS_UNKNOWN_ERROR, \"Bad response \" + response.code() + response.message());\n    }\n\n    private Optional<String> getBearerAuthInfoFromFile()\n    {\n        return bearerTokenFile.map(tokenFileName -> {\n            try {","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-prometheus/src/main/java/com/facebook/presto/plugin/prometheus/PrometheusClient.java#L184-L220","documentation":"The generic catch (IOException e) in fetchUri wraps any non-SSL IO failure while executing the HTTP request or reading the response body and rethrows it as PROMETHEUS_UNKNOWN_ERROR with the message 'Error reading metrics'. It is the catch-all for connection failures, socket timeouts, and body-read errors against the Prometheus API.","triggerScenarios":"fetchUri (via fetchMetrics/PrometheusRecordSet) hitting a refused connection, DNS failure, connect/read timeout, or stream truncation while downloading query results from the Prometheus endpoint.","commonSituations":"Prometheus down or restarted; wrong host/port in connection-url; firewall or NetworkPolicy blocking coordinator→Prometheus traffic; Prometheus timing out on expensive instant/range queries; large query responses dropped.","solutions":["Confirm the Prometheus URL is reachable from the Presto coordinator: curl the connection-url + '/api/v1/query' path","Check Prometheus server logs and health endpoint (/../../-/healthy) for crashes or overload","Increase query timeouts (both Presto and Prometheus) and reduce the time range of the query","Inspect the wrapped cause (PrestoException's cause) for the concrete IOException — connect refused vs timeout vs reset points to different fixes"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Pre-flight check that Prometheus is reachable from the coordinator\ncurl -fsS --max-time 5 http://prometheus.example.com:9090/-/healthy","typeGuard":null,"tryCatchPattern":"catch (PrestoException e) {\n  if (PROMETHEUS_UNKNOWN_ERROR.equals(e.getErrorCode().getName()) && \"Error reading metrics\".equals(e.getMessage())) {\n    // transient IO: backoff and retry, or surface connectivity guidance\n    retryWithBackoff();\n  } else throw e;\n}","preventionTips":["Monitor Prometheus health endpoint and alert on unreachability","Open firewall/NetworkPolicy paths from coordinator to Prometheus before catalog setup","Keep queries time-bounded so responses don't time out or truncate","Log and inspect the cause chain to distinguish refused vs timeout vs reset"],"tags":["io","network","http","prometheus"],"backgroundTag":"http-request-io-error","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}