Querying Instance Metadatas

Last Updated At: 2025-11-26 15:44:38

Instance metadata refers to data related to an instance and can be used to configure or manage the running instance.

Note:

Although instance metadata can only be accessed from within the instance itself, the data is not encrypted. Anyone who can access an instance can view its metadata. Therefore, it is recommended that you take appropriate precautions to protect sensitive data (such as using persistent encryption keys).

Instance Metadata Classification

Provide the following metadata information:

Data Description Introducing Version
instance-id Instance ID 1.0
instance-name Instance Name 1.0
uuid Instance ID 1.0
local-ipv4 The private IP address of the instance 1.0
public-ipv4 The public IP address of the instance 1.0
mac The mac address of the instance eth0 device 1.0
placement/region Information about the region where the instance is located Updated on 2017-09-19
placement/zone Information about the availability zone where the instance is located Updated on 2017-09-19
network/interfaces/macs/${mac}/mac Device address of the instance network API 1.0
network/interfaces/macs/${mac}/primary-local-ipv4 Primary private IP address of the instance network API 1.0
network/interfaces/macs/${mac}/public-ipv4s Public IP address of the instance network API 1.0
network/interfaces/macs/${mac}/vpc-id VPC network ID of the instance network API Updated on 2017-09-19
network/interfaces/macs/${mac}/subnet-id Subnet ID of the instance network API Updated on 2017-09-19
network/interfaces/macs/${mac}/local-ipv4s/${local-ipv4}/gateway Gateway address of the instance network API 1.0
network/interfaces/macs/${mac}/local-ipv4s/${local-ipv4}/local-ipv4 Private IP address of the instance network API 1.0
network/interfaces/macs/${mac}/local-ipv4s/${local-ipv4}/public-ipv4 Public IP address of the instance network API 1.0
network/interfaces/macs/${mac}/local-ipv4s/${local-ipv4}/public-ipv4-mode Public network mode of the instance network API 1.0
network/interfaces/macs/${mac}/local-ipv4s/${local-ipv4}/subnet-mask Subnet mask of the instance network API 1.0
payment/charge-type Instance billing type Updated on 2017-09-19
payment/create-time Instance Creation Time Updated on 2017-09-19
payment/termination-time Instance destruction time Updated on 2017-09-19
app-id AppId of the user to whom the instance belongs Updated on 2017-09-19
as-group-id ID of the auto scaling group where the instance is located Updated on 2017-09-19
spot/termination-time Spot instance destruction time Updated on 2017-09-19
/instance/bandwidth-limit-egress The outbound bandwidth limit of the instance private network, in Kbit/s Updated on 2017-09-19
/instance/bandwidth-limit-ingress The inbound bandwidth limit of the instance private network, in Kbit/s Updated on 2017-09-19
/meta-data/instance/instance-type Instance Specifications Updated on 2017-09-19
/instance/image-id Instance image ID Updated on 2017-09-19
/instance/security-group Instance bound to security group information Updated on 2017-09-19
/volumes get disk id 2025-06-06 update
/volumes/${disk_id}/disk-type Get the disk type 2025-06-06 update
/ntp/servers Get the ntp server address 2025-06-06 update
Note:

The fields ${mac} and ${local-ipv4} in the above table represent the device address and private IP address of the specified network interface of the instance, respectively.

The target URL of the request is case sensitive. Construct the target URL address of the new request strictly according to the return result of the request.

The current version has changed the placement returned data. If you need to use the data of the previous version, you can specify the previous version path or not specify the version path to access the data of version 1.0. For the placement return data, see Region and Availability Zone.

Query Instance Metadata

Within the instance, you can access the instance's local IP, public network IP, and other data through instance metadata to manage connections with external applications.
To verify the display of instance metadata for all categories from within a running instance, use the following URI:

http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/

You can access metadata using the cURL tool or GET request of HTTP, for example:

curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/
  • For non-existent resources, the HTTP error code 404 - Not Found is returned.
  • Operations on instance metadata can only be performed from within the instance. Complete the instance log-in operation first. For more information about logging in to the instance, see Logging in to the Windows Instance and Logging in to the Linux Instance.

Query Metadata Example

The following example shows how to obtain metadata version information.

Note:

When Converge Cloud modifies the metadata access path or the returned data, a new metadata version will be released. If your application or script depends on the structure or the returned data of the previous version, you can use the specified earlier version to access the metadata. If no version is specified, version 1.0 is accessed by default.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/
1.0
2017-09-19
latest
meta-data

The following example shows how to view the metadata root directory. Among them, words ending with / indicate the directory, and words not ending with / indicate access to data. For the specific meaning of access data, see the previous Instance Metadata Classification.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/
instance-id
instance-name
local-ipv4
mac
network/
placement/
public-ipv4
uuid

The following example shows how to obtain the physical location information of the instance. For the relationship between the returned data and physical location, see Region and Availability Zone.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/placement/region
ap-cityA

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/placement/zone
ap-cityA-3

The following example shows how to obtain the private IP address of the instance. If the instance has multiple network interface, the network address of the eth0 device is returned.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/local-ipv4
10.104.13.59

The following example shows how to obtain the public IP address of the instance.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/public-ipv4
139.199.11.29

The following example shows how to obtain the instance ID. The instance ID is the unique identifier of the instance.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/instance-id
ins-3g445roi

The following example shows how to obtain the instance uuid. The instance uuid can be used as the unique identifier of the instance. It is recommended to use the instance ID to distinguish instances.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/uuid
cfac763a-7094-446b-a8a9-b995e638471a

The following example shows how to obtain the mac address of the instance eth0 device.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/mac
52:54:00:BF:B3:51

The following example shows how to obtain instance network interface information. Multiple network interfaces will return multiple lines of data, each line of data is the data directory of one network interface.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/
52:54:00:BF:B3:51/

The following example shows how to obtain information about a specified network interface.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/
local-ipv4s/
mac
vpc-id
subnet-id
owner-id
primary-local-ipv4
public-ipv4s
local-ipv4s/

The following example shows how to obtain information about the Virtual Private Cloud to which a specified network interface belongs.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/vpc-id
vpc-ja82n9op

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/subnet-id
subnet-ja82n9op

The following example shows how to obtain the list of private IP addresses bound to a specified network interface. If the network interface is bound to multiple private IP addresses, multiple lines of data will be returned.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/local-ipv4s/
10.104.13.59/

The following example shows how to obtain the private IP address information.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/local-ipv4s/10.104.13.59
gateway
local-ipv4
public-ipv4
public-ipv4-mode
subnet-mask

The following example shows how to obtain the private IP address gateway. This data can only be queried for VPC models. For VPC models, see Virtual Private Cloud.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/local-ipv4s/10.104.13.59/gateway
10.15.1.1

The following example shows how to obtain a private IP address to access the public network. This data can only be queried for VPC models. Basic network models access the public network through a public network gateway.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/local-ipv4s/10.104.13.59/public-ipv4-mode
NAT

The following example shows how to obtain a private IP address to bind to the public network IP.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/local-ipv4s/10.104.13.59/public-ipv4
139.199.11.29

The following example shows how to obtain the subnet mask of the private IP address.

[qcloud-user]# curl http://product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/network/interfaces/macs/52:54:00:BF:B3:51/local-ipv4s/10.104.13.59/subnet-mask
255.255.192.0

The following example shows how to obtain the instance billing type.

[qcloud-user]# curl product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/payment/charge-type
POSTPAID_BY_HOUR

The following example shows how to obtain the instance creation time.

[qcloud-user]# curl product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/payment/create-time
2018-09-18 11:27:33

The following example shows how to obtain the instance destruction time. (Prepaid mode only)

[qcloud-user]# curl product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/payment/termination-time
2018-10-18 11:27:33

The following example shows how to obtain the instance destruction time for a spot instance.

[qcloud-user]# curl product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/spot/termination-time
2018-08-18 12:05:33

The following example shows how to obtain the AppId of the account to which the sub-machine belongs.

[qcloud-user]# curl product-cvm-metadata.${region_name}.${domain_name}/latest/meta-data/app-id
123456789

Query Instance User Data

You can specify instance user data when creating an instance, which can be accessed by the child machine after setting cloud-init.

Retrieve User Data

Users can access user data in the following ways within the child machine.

[qcloud-user]# curl product-cvm-metadata.${region_name}.${domain_name}/latest/user-data
179, client, cityS