Updated on 2024-03-18 GMT+08:00

Overview

ResourceQL provides SQL-like functions, allowing you to flexibly query your cloud resources.

SELECT name, created, updated FROM resources WHERE region_id = 'regionid1'

The statement is case insensitive. SELECT COUNT(*) and select CoUnT(*) are the same. Use single quotation marks to represent the literal of a string.

The following are data types supported by ResourceQL. For the array type, [] is used to index a position, and the number starts from 1.

Table 1 Supported data types

Type Name

Type

Integer

Int/Integer

Float

Float/Double

Boolean

Boolean

Array

Array

String

String

Dictionary

Object

Timestamp

Date

All your cloud resources are included in a table. The table name is fixed to resources. The resources under your aggregator account forms a table. The table name is fixed to aggregator_resources. Each row in the table records a piece of data. The conventions of each column are as follows.

Table 2 Parameter descriptions in table resources

Parameter

Type

Description

id

String

Specifies the resource ID.

name

String

Specifies the resource name.

provider

String

Specifies the cloud service name.

type

String

Specifies the resource type.

region_id

String

Specifies the region ID.

project_id

String

Specifies the project ID.

ep_id

String

Specifies the enterprise project ID.

checksum

String

Specifies the resource checksum.

created

Date

Specifies the time when the resource was created.

updated

Date

Specifies the time when the resource was updated.

provisioning_state

String

Specifies the result of an operation on resources.

tag

Array(Map<String,String>)

Specifies the resource tag.

properties

Map<String,Object>

Specifies the resource attribute details.

aggregator_resources contains domain_id that indicates the account ID. The type of a domain ID is a string.

Different types of resources can be distinguished by provider and type, and the structures of their properties field are different. For example, cloudservers of an ECS has properties that contains 23 fields, and a VPC has properties that contains only three fields.

For details about the field types supported by the properties parameter, see Creating a Query. The field types supported by the properties parameter are also specified on the console when you create a new query.

For a specific resource type, you can use commas (.), a nesting method, to query the specific fields in properties. For example, if properties of an ECS contains the status and addresses fields, you can run the following statement to query the running ECS and its address:

SELECT name, created, updated, properties.addresses FROM resources 
	WHERE provider = 'ecs' AND type = 'cloudservers' AND properties.status = 'ACTIVE'