Polyv Help Center

Help Center

Query Health Status

Updated: 2022-09-02 18:08:07

API Description

1、通过健康检查来判断后端服务的可用性
2、接口支持https协议

API URL

http://api.polyv.net/live/v4/group/health-check

Request Method

GET

API Constraints

  1. The API supports both HTTP and HTTPS. HTTPS is recommended to ensure security. API calls are subject to rate limits. See details

  2. For group account APIs, use the appId and appSecret of the primary group account when calculating the signature.

Request Parameter Description

Parameter Required Type Description
appId true String Primary group account appId
timestamp true Long Current 13-digit millisecond timestamp, valid for 3 minutes
sign true String Signature, a 32-character uppercase MD5 value. The appSecret key used to generate the signature is critical for communication data security. It must never be stored or used directly on the client side. All APIs must be called through the customer's own server to relay requests to the POLYV server for response data. See signature generation rules

Example

http://api.polyv.net/live/v4/group/health-check?appId=ga1ayl6dh2&timestamp=1661443126000&sign=9AEBDA585085BE8F6299F7DBB443F5D4

Response Parameter Description

Parameter Type Description
code Integer Status code, same as HTTP status code, used to determine the basic response status
status String Response result, determined by the business. Returns "success" on success, "error" on failure
success Boolean Whether the response was successful
requestId String Request ID, a unique UUID generated for each request. Only used for troubleshooting and debugging, should not be tied to business logic
error Object Error information when the status code is not 200. See Error field description
data Object See data field description

Error Parameter Description

Parameter Type Description
code Integer Error code, used to identify the specific error reason
desc String Error description, corresponding to error.code

Data Parameter Description

Parameter Type Description
health Float Health status, rounded to two decimal places, score range 0~100
(0,30] : Low load
(30,60] : Medium load
(60,90] : High load
(90,100] : Critical

Java Request Example

private static final Logger log = LoggerFactory.getLogger(GroupTestLive.class);
/**
 * 查询健康状态
 * @throws IOException
 * @throws NoSuchAlgorithmException
 */
@Test
public void healthCheckTest() throws IOException, NoSuchAlgorithmException {
    //公共参数,填写自己的实际参数
    String appId = super.groupAppId;
    String appSecret = super.groupAppSecret;
    String timestamp = String.valueOf(System.currentTimeMillis());
    
    //业务参数
    String url = "http://api.polyv.net/live/v4/group/health-check";
    
    //http 调用逻辑
    Map<String, String> requestMap = new HashMap<>();
    requestMap.put("appId", appId);
    requestMap.put("timestamp", timestamp);
    requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
    
    String response = HttpUtil.get(url, requestMap);
    log.info("测试查询健康状态成功:{}", response);
    //do somethings
}

Response Example

For system-wide error descriptions, see Global Error Description

Success Example

{
    "code": 200,
    "status": "success",
    "requestId": "c7e83b9751fa4bfe9f57ba45494c147a.57.16529371726540445",
    "data": {
        "health": 1.61
    },
    "success": true
}

Error Example

{
    "code": 400,
    "status": "error",
    "error": {
        "code": 10003,
        "desc": "时间戳过期"
    },
    "success": false
}
联系客服,在线咨询