Querying Job Monitoring Information
Sample Code
You can use the API to query job monitoring information. Monitoring information about multiple jobs can be queried at the same time. Sample code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | // Import classes:
import com.huaweicloud.cs.java.v1.client.ApiException;
import com.huaweicloud.cs.java.v1.MetricApi;
MetricApi apiInstance = new MetricApi(apiClient);//apiClient is created when initializing a CS API client.
String xProjectId = "xProjectId_example"; // String | Project ID used for obtaining the token for the project.
Body3 body = new Body3(); // Body3 | Query job monitoring information. Monitoring information about multiple jobs can be queried at the same time. Request parameters are in the JSON format.
List<Integer> jobIds = new ArrayList<Integer>();
Integer jobId = 49717; // ID of the monitored job.
jobIds.add(jobId);
body.setJobIds(jobIds);
try {
QueryJobMetricsResponse result = apiInstance.getJobsMetrics(xProjectId, body);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling MetricApi#getJobsMetrics");
System.err.println(e.getResponseBody());
e.printStackTrace();
}
|
Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| xProjectId | Yes | String | Project ID. This parameter is used to obtain the token for the project. |
| body | Yes | List<Integer> | Monitoring information to be queried. Multiple job monitoring tasks can be queried at the same time. Request parameters are in the JSON format. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| messageId | No | String | Message type ID. |
| message | No | String | Message content. |
| currentTime | No | Integer | Current time, expressed by milliseconds. |
| payload | No | - | For details about parameter types, see Table 3. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| jobId | No | Integer | Job ID. |
| metrics | No | - | For details about parameter types, see Table 4. |
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| sources | No | - | For details about parameter types, see Table 5. |
| sinks | No | - | |
| totalReadRate | No | Double | Total read rate. Unit: records per second |
| totalWriteRate | No | Double | Total write rate. Unit: records per second |
Last Article: Querying Job Audit Logs
Next Article: Querying the APIG Address of a Job
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.