Table: hcloud_server - Query Hetzner Cloud Servers using SQL
Hetzner Cloud is a cloud infrastructure solutions provider that offers scalable and cost-effective cloud servers. These servers are located in multiple data centers across the globe, providing high-performance and reliable cloud services. Hetzner Cloud servers are ideal for a wide range of applications, including web hosting, development environments, and high-traffic websites.
Table Usage Guide
The hcloud_server
table offers insights into the servers hosted on Hetzner Cloud. As a system administrator or a DevOps engineer, you can explore server-specific details through this table, including server status, location, type, and associated metadata. Use it to monitor server availability, manage server resources, and track the performance of your cloud infrastructure.
Examples
List all servers
Explore a comprehensive list of all servers in a structured order based on their names. This is useful for maintaining an organized inventory of servers and simplifying server management tasks.
select *from hcloud_serverorder by name;
select *from hcloud_serverorder by name;
Get server by name
Discover the segments that pertain to a specific server by its name. This is particularly useful in a scenario where you want to understand the configuration and details of a specific server within your infrastructure.
select *from hcloud_serverwhere name = 'ubuntu-2gb-hel1-1';
select *from hcloud_serverwhere name = 'ubuntu-2gb-hel1-1';
List servers with IPs
Explore which servers have assigned IP addresses, both private and public. This could be useful for network management and troubleshooting connectivity issues.
select name, priv ->> 'IP' as private_ipv4, public_net -> 'IPv4' ->> 'IP' as public_ipv4, public_net -> 'IPv6' ->> 'IP' as public_ipv6from hcloud_server as s, jsonb_array_elements(s.private_net) as privorder by name;
select s.name, json_extract(priv.value, '$.IP') as private_ipv4, json_extract(pub.value, '$.IPv4.IP') as public_ipv4, json_extract(pub.value, '$.IPv6.IP') as public_ipv6from hcloud_server as s, json_each(s.private_net) as priv, json_each(s.public_net) as puborder by s.name;
List servers with server type information
Explore which servers are associated with specific server types, including details like the number of cores and CPU type. This can be beneficial in managing resources and understanding hardware specifications across your server infrastructure.
select s.name as server_name, st.name as server_type_name, st.cores, st.cpu_typefrom hcloud_server as s, hcloud_server_type as stwhere s.server_type_id = st.id;;
select s.name as server_name, st.name as server_type_name, st.cores, st.cpu_typefrom hcloud_server as s join hcloud_server_type as st on s.server_type_id = st.id;
List all volumes for all servers
Determine the areas in which server storage is being utilized by listing all volumes across all servers. This can help in assessing storage distribution and planning for capacity management.
select s.name as server_name, v.name as volume_name, v.sizefrom hcloud_server as s, jsonb_array_elements(s.volume_ids) as sv, hcloud_volume as vwhere sv :: int = v.id;
select s.name as server_name, v.name as volume_name, v.sizefrom hcloud_server as s, json_each(s.volume_ids) as sv, hcloud_volume as vwhere CAST(sv.value AS INTEGER) = v.id;
Schema for hcloud_server
Name | Type | Operators | Description |
---|---|---|---|
_ctx | jsonb | Steampipe context in JSON form. | |
backup_window | text | Time window (UTC) in which the backup will run, or null if the backups are not enabled. | |
created | timestamp with time zone | Point in time when the Server was created. | |
datacenter_id | bigint | Datacenter this Server is located at. | |
id | bigint | = | ID of the Server. |
image_id | bigint | ID of the base image for the server. | |
included_traffic | bigint | Free Traffic for the current billing period in bytes. | |
ingoing_traffic | bigint | Inbound Traffic for the current billing period in bytes. | |
iso | jsonb | ISO Image that is attached to this Server. Null if no ISO is attached. | |
labels | jsonb | User-defined labels (key-value pairs). | |
load_balancers | jsonb | Array of load balancer IDs. | |
locked | boolean | True if Server has been locked and is not available to user. | |
name | text | = | Name of the Server. Must be unique per Project. |
outgoing_traffic | bigint | Outbound Traffic for the current billing period in bytes. | |
placement_group | jsonb | Placement group for the server. | |
primary_disk_size | bigint | Size of the primary Disk. | |
private_net | jsonb | Private network information. | |
protection | jsonb | Protection configuration for the Server. | |
public_net | jsonb | Public network information. The Server's IPv4 address can be found in public_net->ipv4->ip. | |
rescue_enabled | boolean | True if rescue mode is enabled. Server will then boot into rescue system on next reboot. | |
server_type_id | bigint | Type of Server - determines how much ram, disk and cpu a Server has. | |
sp_connection_name | text | =, !=, ~~, ~~*, !~~, !~~* | Steampipe connection name. |
sp_ctx | jsonb | Steampipe context in JSON form. | |
status | text | = | Status of the server: running, initializing, starting, stopping, off, deleting, migrating, rebuilding, unknown. |
volume_ids | jsonb | IDs of Volumes assigned to this Server. |
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_server