Table: alicloud_ecs_disk - Query Alibaba Cloud Elastic Compute Service Disks using SQL
The Alibaba Cloud Elastic Compute Service (ECS) provides scalable, on-demand cloud servers for secure, flexible, and efficient application environments. ECS supports both Linux and Windows OS and offers a variety of instance types optimized to fit different workloads and scenarios. It allows users to manage the underlying physical resources while focusing on developing and deploying applications.
Table Usage Guide
The alicloud_ecs_disk
table provides insights into the Elastic Compute Service Disks within Alibaba Cloud. As a system administrator, explore disk-specific details through this table, including status, type, and size. Utilize it to uncover information about disks, such as those with high usage, the types of disks in use, and the verification of disk sizes.
Examples
Basic info
Explore which Alibaba Cloud Elastic Compute Service (ECS) disks are being used, their sizes, types, and billing methods. This information can help you understand your usage and costs, and make informed decisions about resource allocation and budgeting.
select name, disk_id, arn, size, type, billing_method, zone, regionfrom alicloud_ecs_disk;
select name, disk_id, arn, size, type, billing_method, zone, regionfrom alicloud_ecs_disk;
Unencrypted Disks
Determine the areas in which there are unencrypted disks in your Alicloud ECS instances. This can help in identifying potential security risks and ensuring that all data storage devices comply with encryption standards.
select name, disk_id, encrypted, zone, status, size, instance_id, kms_key_idfrom alicloud_ecs_diskwhere not encrypted;
select name, disk_id, encrypted, zone, status, size, instance_id, kms_key_idfrom alicloud_ecs_diskwhere encrypted = 0;
List of disks Encrypted with Default Service CMK
select name, disk_id, encrypted, zone, status, size, instance_id, kms_key_idfrom alicloud_ecs_diskwhere encrypted and kms_key_id = '';
List Auto Snapshot Policy details applied to disk
This query is used to explore the details of auto snapshot policies applied to encrypted disks in the Alibaba Cloud ECS service. It helps in managing and understanding the security aspects of disk storage by identifying those without a specified Key Management Service (KMS) key ID.
```sql+sqlite```sqlselect name, disk_id, encrypted, zone, status, size, instance_id, kms_key_id from alicloud_ecs_diskwhere encrypted = 1 and kms_key_id = '';
select name, auto_snapshot_policy_id, auto_snapshot_policy_name, auto_snapshot_policy_creation_time, auto_snapshot_policy_enable_cross_region_copy, auto_snapshot_policy_repeat_week_days, auto_snapshot_policy_retention_days, auto_snapshot_policy_status, auto_snapshot_policy_time_points, auto_snapshot_policy_tagsfrom alicloud_ecs_disk;
List of disks without owner tag key
Discover the segments that lack an assigned 'owner' in the disk resource data, allowing for prompt identification and rectification of unassigned resources.
select name, disk_id, tagsfrom alicloud_ecs_diskwhere tags ->> 'owner' is null;
select name, disk_id, tagsfrom alicloud_ecs_diskwhere json_extract(tags, '$.owner') is null;
List disks attached to a specific instance
Determine the specifics of disks attached to a particular instance, such as their size, type, billing method, and encryption status. This can be useful to assess storage usage, cost implications, and security measures.
select name, disk_id, size, type, billing_method, zone, region, encryptedfrom alicloud_ecs_diskwhere instance_id = 'i-0xickpvpsaih9w7s4zrq';
select name, disk_id, size, type, billing_method, zone, region, encryptedfrom alicloud_ecs_diskwhere instance_id = 'i-0xickpvpsaih9w7s4zrq';
List of disks not attached to any instances
Identify the disks that are currently not in use within your system. This can help manage resources more effectively by highlighting potential areas for storage optimization.
select name, disk_id, status, attached_time, detached_timefrom alicloud_ecs_diskwhere status = 'Available';
select name, disk_id, status, attached_time, detached_timefrom alicloud_ecs_diskwhere status = 'Available';
Disk count in each availability zone
Uncover the details of disk distribution across different availability zones to optimize resource allocation and balance load. This can be beneficial for improving system performance and resilience.
select zone, count(*)from alicloud_ecs_diskgroup by zoneorder by count desc;
select zone, count(*)from alicloud_ecs_diskgroup by zoneorder by count(*) desc;
Top 10 largest Disks
Analyze your cloud storage to pinpoint the specific locations where the ten largest disks are in use. This is particularly useful for managing storage resources and planning for capacity upgrades.
select name, disk_id, size, status, instance_idfrom alicloud_ecs_diskorder by size desclimit 10;
select name, disk_id, size, status, instance_idfrom alicloud_ecs_diskorder by size desclimit 10;
List of disks having no attached running instances
Determine the areas in which disks are not being utilized by identifying instances where disks are not attached to any running instances. This query is useful in pinpointing potential resources that may be underutilized or misallocated, helping optimize resource allocation and potentially reducing costs.
select i.instance_id as "Instance ID", i.name as "Name", i.arn as "Instance ARN", i.status as "Instance State", attachment ->> 'AttachedTime' as "Attachment Time"from alicloud_ecs_disk as v, jsonb_array_elements(attachments) as attachment, alicloud_ecs_instance as iwhere i.instance_id = attachment ->> 'InstanceId' and i.status <> 'Running'order by i.instance_id;
select i.instance_id as "Instance ID", i.name as "Name", i.arn as "Instance ARN", i.status as "Instance State", json_extract(attachment.value, '$.AttachedTime') as "Attachment Time"from alicloud_ecs_disk as v, json_each(attachments) as attachment, alicloud_ecs_instance as iwhere i.instance_id = json_extract(attachment.value, '$.InstanceId') and i.status <> 'Running'order by i.instance_id;
Query examples
- ecs_disk_1_year_count
- ecs_disk_24_hours_count
- ecs_disk_30_90_days_count
- ecs_disk_30_days_count
- ecs_disk_90_365_days_count
- ecs_disk_attached_instances_count
- ecs_disk_auto_snapshot
- ecs_disk_auto_snapshot_deletion
- ecs_disk_by_account
- ecs_disk_by_category
- ecs_disk_by_creation_month
- ecs_disk_by_region
- ecs_disk_category
- ecs_disk_count
- ecs_disk_delete_auto_snapshot_count
- ecs_disk_encryption
- ecs_disk_encryption_table
- ecs_disk_input
- ecs_disk_iops
- ecs_disk_overview
- ecs_disk_storage
- ecs_disk_storage_by_account
- ecs_disk_storage_by_category
- ecs_disk_storage_by_creation_month
- ecs_disk_storage_by_region
- ecs_disk_storage_total
- ecs_disk_tags
- ecs_disk_unencrypted_count
- ecs_disks_for_ecs_instance
- ecs_disks_for_kms_key
- ecs_images_for_ecs_disk
- ecs_instances_for_ecs_disk
- ecs_instances_for_ecs_snapshot
- ecs_snapshots_for_ecs_instance
- kms_keys_for_ecs_disk
- source_ecs_disks_for_ecs_snapshot
- source_ecs_snapshots_for_ecs_disk
- target_ecs_disks_for_ecs_snapshot
- target_ecs_snapshots_for_ecs_disk
Control examples
Schema for alicloud_ecs_disk
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
account_id | text | =, !=, ~~, ~~*, !~~, !~~* | The Alicloud Account ID in which the resource is located. |
akas | jsonb | Array of globally unique identifier strings (also known as) for the resource. | |
arn | text | The Alibaba Cloud Resource Name (ARN) of the ECS disk. | |
attached_time | timestamp with time zone | The time when the disk was attached. | |
attachments | jsonb | The attachment information of the cloud disk. | |
auto_snapshot_policy_creation_time | text | The time when the auto snapshot policy was created. | |
auto_snapshot_policy_enable_cross_region_copy | boolean | The ID of the automatic snapshot policy applied to the disk. | |
auto_snapshot_policy_id | text | The ID of the automatic snapshot policy applied to the disk. | |
auto_snapshot_policy_name | text | The name of the automatic snapshot policy applied to the disk. | |
auto_snapshot_policy_repeat_week_days | text | The days of a week on which automatic snapshots are created. Valid values: 1 to 7, which corresponds to the days of the week. 1 indicates Monday. One or more days can be specified. | |
auto_snapshot_policy_retention_days | bigint | The retention period of the automatic snapshot. | |
auto_snapshot_policy_status | text | The status of the automatic snapshot policy. | |
auto_snapshot_policy_tags | jsonb | The days of a week on which automatic snapshots are created. Valid values: 1 to 7, which corresponds to the days of the week. 1 indicates Monday. One or more days can be specified. | |
auto_snapshot_policy_time_points | text | The points in time at which automatic snapshots are created. The least interval at which snapshots can be created is one hour. Valid values: 0 to 23, which corresponds to the hours of the day from 00:00 to 23:00. 1 indicates 01:00. You can specify multiple points in time. | |
billing_method | text | The billing method of the disk. Possible values are: PrePaid and PostPaid. | |
category | text | The category of the disk. | |
creation_time | timestamp with time zone | The time when the disk was created. | |
delete_auto_snapshot | boolean | Indicates whether the automatic snapshots of the disk are deleted when the disk is released. | |
delete_with_instance | boolean | Indicates whether the disk is released when its associated instance is released. | |
description | text | A user provided, human readable description for this resource. | |
detached_time | timestamp with time zone | The time when the disk was detached. | |
device | text | The device name of the disk on its associated instance. | |
disk_id | text | = | An unique identifier for the resource. |
enable_auto_snapshot | boolean | Indicates whether the automatic snapshot policy feature was enabled for the disk. | |
enable_automated_snapshot_policy | boolean | Indicates whether an automatic snapshot policy was applied to the disk. | |
encrypted | boolean | Indicates whether the disk was encrypted. | |
expired_time | timestamp with time zone | The time when the subscription disk expires. | |
image_id | text | The ID of the image used to create the instance. This parameter is empty unless the disk was created from an image. The value of this parameter remains unchanged throughout the lifecycle of the disk. | |
instance_id | text | The ID of the instance to which the disk is attached. This parameter has a value only when the value of Status is In_use. | |
iops | bigint | The number of input/output operations per second (IOPS). | |
iops_read | bigint | The number of I/O reads per second. | |
iops_write | bigint | The number of I/O writes per second. | |
kms_key_id | text | The device name of the disk on its associated instance. | |
mount_instance_num | bigint | The number of instances to which the Shared Block Storage device is attached. | |
mount_instances | jsonb | The attaching information of the disk. | |
name | text | A friendly name for the resource. | |
operation_lock | jsonb | The reasons why the disk was locked. | |
performance_level | text | The performance level of the ESSD. | |
portable | boolean | Indicates whether the disk is removable. | |
product_code | text | The product code in Alibaba Cloud Marketplace. | |
region | text | The Alicloud region in which the resource is located. | |
resource_group_id | text | The ID of the resource group to which the disk belongs. | |
serial_number | text | The serial number of the disk. | |
size | bigint | Specifies the size of the disk. | |
source_snapshot_id | text | The ID of the snapshot used to create the disk. This parameter is empty unless the disk was created from a snapshot. The value of this parameter remains unchanged throughout the lifecycle of the disk. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
status | text | Specifies the current state of the resource. | |
storage_set_id | text | The ID of the storage set. | |
storage_set_partition_number | bigint | The maximum number of partitions in a storage set. | |
tags | jsonb | A map of tags for the resource. | |
tags_src | jsonb | A list of tags attached with the resource. | |
title | text | Title of the resource. | |
type | text | Specifies the type of the disk. Possible values are: 'system' and 'data'. | |
zone | text | The zone name in which the resource is created. |
Export
This table is available as a standalone Exporter CLI. Steampipe exporters are stand-alone binaries that allow you to extract data using Steampipe plugins without a database.
You can download the tarball for your platform from the Releases page, but it is simplest to install them with the steampipe_export_installer.sh
script:
/bin/sh -c "$(curl -fsSL https://steampipe.io/install/export.sh)" -- alicloud
You can pass the configuration to the command with the --config
argument:
steampipe_export_alicloud --config '<your_config>' alicloud_ecs_disk