Query clusters

2023-08-15 11:21:17  Updated

Description

You can call this operation to query OceanBase clusters managed by OCP.

You can query clusters based on conditions such as the keyword of cluster names and cluster status. If OceanBase clusters are deployed in primary/standby mode, both the primary cluster and standby clusters are contained in the returned results. You can determine the role of a cluster based on its attributes.

Call description

Prerequisites

  • You have the CLUSTER_VIEWER permissions.

  • You have passed the authentication for the OCP application service.

Request path

GET /api/v2/ob/clusters

Request parameters

Parameter Type Required Example value Description
page Integer No 1 The number of the page to return. Pages start from page 1. Default value: 1.
size Integer No 10 The number of entries to return on each page. Maximum value: 2000.
sort String No name,asc The rule of sorting the requested data.
name String No foo The keyword of the cluster name, which is case-insensitive.
status StringArray No CREATING,RUNNING The status of the cluster. Valid values: * RUNNING * CREATING * DELETING * STARTING * RESTARTING * STOPPING * STOPPED * TAKINGOVER * MOVINGOUT * SWITCHOVER * FAILOVER * OPERATING: The cluster is being maintained.
withStandby Boolean No True Specifies whether to query only the primary cluster. * If the value is true, only the primary cluster is queried. * If the value is false, all clusters are queried. Default value: false.

Response parameters

Parameter Type Description
data Object The data structure of ObCluster. For more information, see the following table.
├─ contents Array The array of the primary/standby cluster information. For more information about its data structure, see the following table.
├─ page Object The page information.
├─ totalElements Integer The total number of entries.
├─ totalPage Integer The total number of pages.
├─ number Integer The page number of the returned page.
├─ size Integer The number of entries returned per page.
successful Boolean Indicates whether the request was successful.
timestamp Datetime The timestamp when the server completed the request.
duration Integer The time taken by the server to process the request, in milliseconds.
status Integer An HTTP status code.
traceId String The trace ID of the request. This trace ID is used for troubleshooting.
server String The address of the application server that responded to the request.

Data structure of ObCluster

Parameter Type Description
primaryCluster Object The primary cluster of the current cluster.
standbyClusters Array The array of standby clusters of the current cluster.
id Integer The ID of the OceanBase cluster generated by the OCP system.
name String The name of the cluster.
obClusterId Integer The ID of the OceanBase cluster generated by the OceanBase Database system.
obVersion String The version of the cluster.
status String The status of the cluster. Valid values: * RUNNING * CREATING * DELETING * STARTING * RESTARTING * STOPPING * STOPPED * TAKINGOVER * MOVINGOUT * SWITCHOVER * FAILOVER * OPERATING: The cluster is being maintained.
regionCount Integer The number of regions.
rootServers Array The information of the Root Server.
├─ address String The address of the Root Server, following the format of IP:Port.
├─ role String The role of the Root Server. Valid values: * LEADER * FOLLOWER
├─ sql_port Integer The SQL port number.
type String The type of the cluster. Valid values: * PRIMARY * STANDBY
regionCount Integer The number of regions.
tenantCount Integer The number of tenants.
partitionCount Integer The number of partitions.
serverCount Integer The number of OBServers.
delayTime Float The delay of the standby cluster, in seconds.
syncStatus String The primary/standby cluster synchronization status. Valid values: * VALID * DISABLED * SYNCHRONIZING
zones Array The list of zones.
createTime DateTime The creation time.
updateTime DateTime The update time.
creator String The creator of the cluster.
failToQueryFromObReason String The cause of cluster access failure.

Data structure of the zone information

Parameter Type Description
name String The name of the zone.
idcName String The name of the IDC to which the zone belongs.
regionName String The region to which the zone belongs.
servers Array The list of servers.
clusterId Long The ID of the OceanBase cluster generated by the OCP system.
obClusterId Long The ID of the OceanBase cluster generated by the OceanBase Database system.
serverCount Integer The number of servers.
hostCount Integer The number of hosts.

Examples

Sample request

Query the first page of cluster information, with 10 entries on each page.

GET /api/v2/ob/clusters?page=1&size=10

Sample response

{
    "data":{
        "contents":[
            {
                "alarmSummaries":[
                    {
                        "count":0,
                        "level":1,
                        "linkDataUrl":"http://192.168.0.1:8080/api/v2/alarm/alarms?isSubscribedByMe=false&page=1&size=10&level=1&category=OB&status=Active&obCluster=test",
                        "linkUrl":"http://192.168.0.1:8080/alarm/event?isSubscribedByMe=false&page=1&size=10&level=1&category=OB&status=Active&obCluster=test"
                    },
                    {
                        "count":0,
                        "level":2,
                        "linkDataUrl":"http://192.168.0.1:8080/api/v2/alarm/alarms?isSubscribedByMe=false&page=1&size=10&level=2&category=OB&status=Active&obCluster=test",
                        "linkUrl":"http://192.168.0.1:8080/alarm/event?isSubscribedByMe=false&page=1&size=10&level=2&category=OB&status=Active&obCluster=test"
                    },
                    {
                        "count":0,
                        "level":3,
                        "linkDataUrl":"http://192.168.0.1:8080/api/v2/alarm/alarms?isSubscribedByMe=false&page=1&size=10&level=3&category=OB&status=Active&obCluster=test",
                        "linkUrl":"http://192.168.0.1:8080/alarm/event?isSubscribedByMe=false&page=1&size=10&level=3&category=OB&status=Active&obCluster=test"
                    },
                    {
                        "count":0,
                        "level":4,
                        "linkDataUrl":"http://192.168.0.1:8080/api/v2/alarm/alarms?isSubscribedByMe=false&page=1&size=10&level=4&category=OB&status=Active&obCluster=test",
                        "linkUrl":"http://192.168.0.1:8080/alarm/event?isSubscribedByMe=false&page=1&size=10&level=4&category=OB&status=Active&obCluster=test"
                    },
                    {
                        "count":0,
                        "level":5,
                        "linkDataUrl":"http://192.168.0.1:8080/api/v2/alarm/alarms?isSubscribedByMe=false&page=1&size=10&level=5&category=OB&status=Active&obCluster=test",
                        "linkUrl":"http://192.168.0.1:8080/alarm/event?isSubscribedByMe=false&page=1&size=10&level=5&category=OB&status=Active&obCluster=test"
                    }
                ],
                "createTime":"2020-11-29T22:23:12+08:00",
                "creator":"admin",
                "id":1000002,
                "name":"test",
                "obClusterId":4,
                "obVersion":"2.2.73",
                "regionCount":1,
                "rootServers":[
                    {
                        "address":"100.88.121.148:2882",
                        "role":"LEADER",
                        "sql_port":2881
                    }
                ],
                "serverCount":1,
                "standbyClusters":[

                ],
                "status":"RUNNING",
                "tenantCount":0,
                "type":"PRIMARY",
                "zones":[
                    {
                        "idcId":1,
                        "idcName":"hz",
                        "innerStatus":"ACTIVE",
                        "name":"zone1",
                        "operateStatus":"NORMAL",
                        "regionName":"hz",
                        "serverCount":1,
                        "servers":[

                        ],
                        "status":"RUNNING"
                    }
                ]
            }
        ],
        "page":{
            "number":1,
            "size":10,
            "totalElements":1,
            "totalPages":1
        }
    },
    "duration":108,
    "server":"192.168.0.1",
    "status":200,
    "successful":true,
    "timestamp":"2020-12-02T20:03:58.233+08:00",
    "traceId":"3cfec9a5180748ff"
}

Contact Us