Getting information about a VM
To get basic details of each virtual machine you created, open the virtual machine page in management console. To get detailed information with user-defined metadata, use the CLI or API.
You can also get the basic details and metadata from inside a VM.
Get information from outside a VM
On the Virtual machines page in the Compute Cloud section, you can find a list of VMs in the folder and brief information for each of them.
For more information about a certain VM, click its name.
Tabs:
- Overview shows general information about the VM, including the IP addresses assigned to it.
- Disks provides information about the disks attached to the VM.
- Operations lists operations on the VM and resources attached to it, such as disks.
- Monitoring shows information about resource consumption on the VM. You can only get this information from the management console or from inside the VM.
- Serial port provides information that is output by the VM to the serial port. To get this information via the API or CLI, use the instructions Viewing serial port output.
The folder specified in the CLI profile is used by default. You can specify a different folder using the --folder-name
or --folder-id
parameter.
-
View the description of the command to get serial port output:
$ yc compute instance get --help
-
Select a VM, for example,
first-instance
:$ yc compute instance list +----------------------+-----------------+---------------+---------+----------------------+ | ID | NAME | ZONE ID | STATUS | DESCRIPTION | +----------------------+-----------------+---------------+---------+----------------------+ | fhm0b28lgfp4tkoa3jl6 | first-instance | ru-central1-a | RUNNING | my first vm via CLI | | fhm9gk85nj7gcoji2f8s | second-instance | ru-central1-a | RUNNING | my second vm via CLI | +----------------------+-----------------+---------------+---------+----------------------+
-
Get basic information about a VM:
$ yc compute instance get first-instance
To get information about a VM with metadata, use the
--full
flag:$ yc compute instance get --full first-instance
Get information from inside a virtual machine
From inside the VM, the metadata service is accessible at the IP address 169.254.169.254
.
Currently, the Yandex.Cloud metadata service returns metadata in Google Compute Engine and Amazon EC2 formats.
Google Compute Engine
The Yandex.Cloud metadata service lets you return metadata in Google Compute Engine format.
HTTP request
GET http://169.254.169.254/computeMetadata/v1/instance/
? alt=<json|text>
& recursive=<true|false>
& wait_for_change=<true|false>
& last_etag=<string>
& timeout_sec=<int>
Metadata-Flavor: Google
Parameter | Description |
---|---|
alt |
Response format (by default, text ). |
recursive |
If true , it returns all values in the tree recursively. By default, false . |
wait_for_change |
If true , this response will be returned only when one of the metadata parameters is modified. By default, false . |
last_etag |
The ETag value from the previous response to a similar request. Use it when wait_for_change="true" . |
timeout_sec |
Maximum request timeout. Use it when wait_for_change="true" . |
Request examples
Find out the ID of a VM from inside it:
$ curl -H Metadata-Flavor:Google 169.254.169.254/computeMetadata/v1/instance/id
Get metadata in JSON format:
$ curl -H Metadata-Flavor:Google 169.254.169.254/computeMetadata/v1/instance/?recursive=true
Get metadata in an easy-to-read format. Use the jq utility:
$ curl -H Metadata-Flavor:Google 169.254.169.254/computeMetadata/v1/instance/?recursive=true | jq -r '.'
List of returned elements
List of elements that are available for this request.
Element | Description |
---|---|
attributes/ |
User-defined metadata that was passed in the metadata field when creating or updating the VM. |
attributes/ssh-keys |
List of public SSH keys passed during VM creation in the metadata field through the ssh-keys value. |
description |
Text description passed when creating or updating the VM. |
disks/ |
Disks attached to the VM. |
hostname |
FQDN assigned to the VM. |
id |
ID of the VM. The ID is generated automatically when the VM is being created and is unique within Yandex.Cloud. |
name |
Name that was passed when creating or updating the VM. |
networkInterfaces/ |
Network interfaces connected to the VM. |
service-accounts |
Service accounts linked to the VM. |
service-accounts/default/token |
IAM token of the linked service account. |
Other elements, such as project
, which are used for backward compatibility and remain empty.
Amazon EC2
The Yandex.Cloud metadata service lets you return metadata in Amazon EC2 format. This format has no support for user-defined metadata fields.
HTTP request
GET http://169.254.169.254/latest/meta-data/<element>
Parameter | Description |
---|---|
<element> |
Path to the element you want to get. If the element is omitted, the response returns a list of available elements. |
List of returned elements
List of elements that are available for this request.
Note
The angle brackets contain parameters that need to be replaced with values. For example, instead of <mac>
, you should insert the MAC address of the network interface.
Element | Description |
---|---|
hostname |
Hostname assigned to the VM. |
instance-id |
ID of the VM. |
local-ipv4 |
Internal IPv4 address. |
local-hostname |
Hostname assigned to the VM. |
mac |
MAC address of the VM's network interface. |
network/interfaces/macs/<mac>/ipv6s |
Internal IPv6 addresses associated with the network interface. |
network/interfaces/macs/<mac>/local-hostname |
Hostname associated with the network interface. |
network/interfaces/macs/<mac>/local-ipv4s |
Internal IPv4 addresses associated with the network interface. |
network/interfaces/macs/<mac>/mac |
MAC address of the VM's network interface. |
public-ipv4 |
External IPv4 address. |
Request examples
Get an internal IP address from inside a VM:
$ curl http://169.254.169.254/latest/meta-data/local-ipv4