steampipe plugin install hcloud

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_server
order by
name;
select
*
from
hcloud_server
order 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_server
where
name = 'ubuntu-2gb-hel1-1';
select
*
from
hcloud_server
where
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_ipv6
from
hcloud_server as s,
jsonb_array_elements(s.private_net) as priv
order 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_ipv6
from
hcloud_server as s,
json_each(s.private_net) as priv,
json_each(s.public_net) as pub
order 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_type
from
hcloud_server as s,
hcloud_server_type as st
where
s.server_type_id = st.id;
;
select
s.name as server_name,
st.name as server_type_name,
st.cores,
st.cpu_type
from
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.size
from
hcloud_server as s,
jsonb_array_elements(s.volume_ids) as sv,
hcloud_volume as v
where
sv :: int = v.id;
select
s.name as server_name,
v.name as volume_name,
v.size
from
hcloud_server as s,
json_each(s.volume_ids) as sv,
hcloud_volume as v
where
CAST(sv.value AS INTEGER) = v.id;

Schema for hcloud_server

NameTypeOperatorsDescription
_ctxjsonbSteampipe context in JSON form.
backup_windowtextTime window (UTC) in which the backup will run, or null if the backups are not enabled.
createdtimestamp with time zonePoint in time when the Server was created.
datacenter_idbigintDatacenter this Server is located at.
idbigint=ID of the Server.
image_idbigintID of the base image for the server.
included_trafficbigintFree Traffic for the current billing period in bytes.
ingoing_trafficbigintInbound Traffic for the current billing period in bytes.
isojsonbISO Image that is attached to this Server. Null if no ISO is attached.
labelsjsonbUser-defined labels (key-value pairs).
load_balancersjsonbArray of load balancer IDs.
lockedbooleanTrue if Server has been locked and is not available to user.
nametext=Name of the Server. Must be unique per Project.
outgoing_trafficbigintOutbound Traffic for the current billing period in bytes.
placement_groupjsonbPlacement group for the server.
primary_disk_sizebigintSize of the primary Disk.
private_netjsonbPrivate network information.
protectionjsonbProtection configuration for the Server.
public_netjsonbPublic network information. The Server's IPv4 address can be found in public_net->ipv4->ip.
rescue_enabledbooleanTrue if rescue mode is enabled. Server will then boot into rescue system on next reboot.
server_type_idbigintType of Server - determines how much ram, disk and cpu a Server has.
sp_connection_nametext=, !=, ~~, ~~*, !~~, !~~*Steampipe connection name.
sp_ctxjsonbSteampipe context in JSON form.
statustext=Status of the server: running, initializing, starting, stopping, off, deleting, migrating, rebuilding, unknown.
volume_idsjsonbIDs 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