Table: hcloud_placement_group - Query Hetzner Cloud Placement Groups using SQL
A Placement Group in Hetzner Cloud is a resource used to determine the physical location of servers. It provides an overview of the server's placement group, including its type and servers. The placement group's type can be either "spread" or "cluster", and it is used to control the distribution of servers within the same data center.
Table Usage Guide
The hcloud_placement_group
table provides insights into Placement Groups within Hetzner Cloud. As a Cloud Engineer, you can explore placement group-specific details through this table, including their type and associated servers. Utilize it to manage the distribution of servers within the same data center, ensuring optimal performance and availability.
Examples
List placement groups
Explore the organization of your server infrastructure by identifying the groups in which your servers are placed. This can help to understand the distribution and categorization of your servers, thereby aiding in efficient resource management.
select id, name, type, serversfrom hcloud_placement_grouporder by id;
select id, name, type, serversfrom hcloud_placement_grouporder by id;
List placement groups with the label env=prod
Discover the segments that have been labeled as 'production environment' within your placement groups. This is useful for understanding how resources are allocated and managed within your production environment.
select id, name, labels, serversfrom hcloud_placement_groupwhere labels ->> 'env' = 'prod';
select id, name, labels, serversfrom hcloud_placement_groupwhere json_extract(labels, '$.env') = 'prod';
Get server details for servers in placement groups
This query is useful for identifying the status and other details of servers located within specific placement groups. This can help in managing and monitoring server performance and resource allocation more effectively.
with placement_groups as ( select p.name, p.type, server_id from hcloud_placement_group as p, jsonb_array_elements(servers) as server_id)select p.name as placement_group_name, p.type as placement_group_type, s.name as server_name, s.status as server_status, s.image_id as server_image_id, s.id as server_idfrom placement_groups as p, hcloud_server as swhere s.id :: text = p.server_id :: text;
with placement_groups as ( select p.name, p.type, json_extract( server_id.value, ') as server_id from hcloud_placement_group as p, json_each(servers) as server_id)select p.name as placement_group_name, p.type as placement_group_type, s.name as server_name, s.status as server_status, s.image_id as server_image_id, s.id as server_idfrom placement_groups as p, hcloud_server as swhere s.id = p.server_id;
Schema for hcloud_placement_group
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
created | timestamp with time zone | Point in time (in ISO-8601 format) when the placement group was created. | |
id | bigint | = | ID of the placement group. |
labels | jsonb | User-defined labels (key-value pairs). | |
name | text | = | Unique user-defined name of the placement group. |
servers | jsonb | Array of IDs of servers that are part of this placement group. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
type | text | Type of placement group. |
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)" -- hcloud
You can pass the configuration to the command with the --config
argument:
steampipe_export_hcloud --config '<your_config>' hcloud_placement_group