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

Table 1 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.

Table 2 Parameters involved in QueryJobMetricsResponse

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.

Table 3 Parameters involved in JobMetric

Parameter

Mandatory

Type

Description

jobId

No

Integer

Job ID.

metrics

No

-

For details about parameter types, see Table 4.

Table 4 Parameters involved in JobMetricDetail

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

Table 5 Parameters involved in OperatorMetric

Parameter

Mandatory

Type

Description

name

No

String

Name of an operator.

records

No

Integer

Number of records.

corruptedRecords

No

Integer

Number of dirty data records.