Help Center/ Web3 Node Engine Service/ API Reference/ API/ Node Monitoring/ Obtaining the Node Monitoring Information
Updated on 2023-08-08 GMT+08:00

Obtaining the Node Monitoring Information

Description

This API is used to obtain the node information, including the CPU usage, memory usage, uplink/downlink network traffic, storage, and disk read/write.

URI

POST /v1/{project_id}/node-provider/nodes/{node_id}/metrics

Table 1 URI parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID.

Minimum length: 32 characters

Maximum length: 32 characters

node_id

Yes

String

Node ID.

Minimum length: 36 characters

Maximum length: 45 characters

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token.

Minimum length: 1 character

Maximum length: 65,535 characters

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

metric_names

No

Array of strings

Metrics. Options: cpuUsage: CPU usage. diskUsedRate: disk usage. memUsedRate: physical memory usage. sendBytesRate: uplink rate (byte/s). recvBytesRate: downlink rate (byte/s). cpuCoreLimit: total CPU cores. cpuCoreUsed: used CPU cores. totalMem: total physical memory. freeMem: available physical memory. diskCapacity: disk capacity. diskAvailableCapacity: available disk space. By default, the first five metrics are used.

period

Yes

Integer

Monitoring data granularity. For example, 60 indicates 1 minute and 300 indicates 5 minutes.

Minimum value: 0

Maximum value: 86,400

timerange

Yes

String

Query time range. For example, -1.-1.60 indicates the latest 60 minutes (startTimeInMillis.endTimeInMillis.durationInMinutes).

Minimum length: 0 characters

Maximum length: 100 characters

statistics

Yes

Array of strings

Statistical mode, which can be maximum, minimum, sum, average, or sampleCount.

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

metrics

Array of MetricItemResultAPI objects

Metric list.

Table 5 MetricItemResultAPI

Parameter

Type

Description

metric

MetricDemision object

Metric description.

dataPoints

Array of MetricDataPoints objects

Basic information of the monitoring data.

Table 6 MetricDemision

Parameter

Type

Description

namespace

String

Namespace.

Minimum length: 1 character

Maximum length: 65,535 characters

metricName

String

Metric name.

Minimum length: 1 character

Maximum length: 65,535 characters

dimensions

Array of Dimension objects

Dimension list.

Table 7 Dimension

Parameter

Type

Description

name

String

Dimension name.

Minimum length: 1 character

Maximum length: 65,535 characters

value

String

Dimension value.

Minimum length: 1 character

Maximum length: 65,535 characters

Table 8 MetricDataPoints

Parameter

Type

Description

timestamp

String

Timestamp.

Minimum length: 0 characters

Maximum length: 100 characters

unit

String

Metric unit.

Minimum length: 1 character

Maximum length: 65,535 characters

statistics

Array of StatisticValue objects

Statistical mode.

Table 9 StatisticValue

Parameter

Type

Description

statistic

String

Statistical mode.

Minimum length: 1 character

Maximum length: 65,535 characters

value

Double

Statistics result.

Minimum value: 0

Maximum value: 2,147,483,647

Status code: 400

Table 10 Response body parameters

Parameter

Type

Description

code

String

Status code.

Minimum length: 3 characters

Maximum length: 3 characters

error_code

String

Error code.

Minimum length: 12 characters

Maximum length: 12 characters

error_msg

String

Error message.

Minimum length: 1 character

Maximum length: 65,535 characters

message

String

Error details.

Minimum length: 0 characters

Maximum length: 65,535 characters

Status code: 401

Table 11 Response body parameters

Parameter

Type

Description

code

String

Status code.

Minimum length: 3 characters

Maximum length: 3 characters

error_code

String

Error code.

Minimum length: 12 characters

Maximum length: 12 characters

error_msg

String

Error message.

Minimum length: 1 character

Maximum length: 65,535 characters

message

String

Error details.

Minimum length: 0 characters

Maximum length: 65,535 characters

Status code: 500

Table 12 Response body parameters

Parameter

Type

Description

code

String

Status code.

Minimum length: 3 characters

Maximum length: 3 characters

error_code

String

Error code.

Minimum length: 12 characters

Maximum length: 12 characters

error_msg

String

Error message.

Minimum length: 1 character

Maximum length: 65,535 characters

message

String

Error details.

Minimum length: 0 characters

Maximum length: 65,535 characters

Example Request

{
  "metric_names" : [ "cpuUsage" ],
  "period" : 300,
  "timerange" : "-1.-1.60",
  "statistics" : [ "maximum" ]
}

Example Response

Status code: 200

Request successful.

{
  "metrics" : [ {
    "metric" : {
      "namespace" : "123",
      "metricName" : "cpuUsage",
      "dimensions" : [ {
        "name" : "nodeIP",
        "value" : "192.168.0.1"
      } ]
    },
    "dataPoints" : [ {
      "timestamp" : 1686059700000,
      "unit" : "Percent",
      "statistics" : [ {
        "statistic" : "average",
        "value" : 20
      } ]
    } ]
  } ]
}

Status code: 400

Verify parameter failed.

{
  "code" : 400,
  "error_code" : "BCS.03400001",
  "error_msg" : "Invalid request.",
  "message" : "unmarshal request data error"
}

Status code: 401

Authentication failed.

{
  "code" : 401,
  "error_code" : "BCS.03401001",
  "error_msg" : "Authorization failed.",
  "message" : "request token is not valid"
}

Status code: 500

Internal service error.

{
  "code" : 500,
  "error_code" : "BCS.03500001",
  "error_msg" : "Internal error.",
  "message" : "project [xxx] node [xxx] get service bearer user token error"
}

Status Code

Status Code

Description

200

Request successful.

400

Verify parameter failed.

401

Authentication failed.

500

Internal service error.

Error Code

For details, see Error Codes.