Kris20030907 opened a new issue, #652:
URL: https://github.com/apache/rocketmq-dashboard/issues/652

   ## Background
   
   The data source management page already provides a connection test action 
through `POST /api/settings/datasources/test`.
   
   However, the backend implementation is currently a placeholder that returns 
a successful result without sending a request to the configured data source.
   
   ## Expected behavior
   
   Complete the reserved connection test capability by performing a lightweight 
Prometheus-compatible query for Prometheus, VictoriaMetrics, and Thanos data 
sources, then report whether the connection and response are valid.
   
   Connection timeout, non-2xx responses, unsupported types, invalid URLs, and 
malformed Prometheus responses should return `data.success: false`.
   
   ## API example
   
   Request:
   
   ```http
   POST /api/settings/datasources/test
   Content-Type: application/json
   ```
   
   ```json
   {
     "type": "Prometheus",
     "url": "http://prometheus-pub.mioffice.cn";,
     "auth": "None"
   }
   ```
   
   Successful response:
   
   ```json
   {
     "code": 200,
     "message": "success",
     "data": {
       "success": true,
       "message": "Connection successful"
     }
   }
   ```
   
   Failed connection response:
   
   ```json
   {
     "code": 200,
     "message": "success",
     "data": {
       "success": false,
       "message": "Failed to connect to data source"
     }
   }
   ```
   
   The outer `code` and `message` represent successful handling of the API 
request. The actual connection result is represented by `data.success`, while 
`data.message` contains the connection test result.
   
   ## Proposed fix
   
   - Query `/api/v1/query` with the lightweight PromQL expression `vector(1)`.
   - Support Prometheus-compatible Prometheus, VictoriaMetrics, and Thanos 
endpoints.
   - Apply bounded connection and read timeouts.
   - Validate the Prometheus response structure before reporting success.
   - Return a clear failure message for unreachable endpoints, upstream HTTP 
errors, invalid URLs, and malformed responses.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to