Managing Hetzner Cloud (Deep Dive)
Deep-dive Hetzner Cloud management using the hcloud CLI for detailed analysis.
MANDATORY: Discovery-First Pattern
Always discover available resources before performing analysis.
Phase 1: Discovery
#!/bin/bash
echo "=== Server Types (Available) ==="
hcloud server-type list -o columns=id,name,description,cores,memory,disk,storage_type 2>/dev/null | head -20
echo ""
echo "=== Placement Groups ==="
hcloud placement-group list -o columns=id,name,type,servers 2>/dev/null | head -10
echo ""
echo "=== Primary IPs ==="
hcloud primary-ip list -o columns=id,name,type,ip,datacenter,assignee_id,auto_delete 2>/dev/null | head -10
echo ""
echo "=== Certificates ==="
hcloud certificate list -o columns=id,name,type,domain_names,not_valid_after 2>/dev/null | head -10
echo ""
echo "=== Images ==="
hcloud image list --type system -o columns=id,name,description,os_flavor,os_version,disk_size 2>/dev/null | head -15
echo ""
echo "=== Snapshots ==="
hcloud image list --type snapshot -o columns=id,description,created,image_size,disk_size 2>/dev/null | head -10
echo ""
echo "=== Backups ==="
hcloud image list --type backup -o columns=id,description,created,image_size,created_from_name 2>/dev/null | head -10
Phase 2: Analysis
#!/bin/bash
SERVER_ID="${1:?Server ID required}"
echo "=== Server Details ==="
hcloud server describe "$SERVER_ID" -o json 2>/dev/null | jq '{
id, name, status,
server_type: .server_type.name,
cores: .server_type.cores,
memory: .server_type.memory,
disk: .server_type.disk,
datacenter: .datacenter.name,
location: .datacenter.location.city,
public_ipv4: .public_net.ipv4.ip,
public_ipv6: .public_net.ipv6.ip,
private_nets: [.private_net[] | {network: .network, ip: .ip}],
image: .image.name,
iso: .iso,
rescue_enabled: .rescue_enabled,
locked: .locked,
protection: .protection,
labels: .labels,
created: .created
}'
echo ""
echo "=== Server Metrics (CPU last 1h) ==="
hcloud server metrics "$SERVER_ID" --type cpu --start "$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" --end "$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o json 2>/dev/null | jq '.metrics.timeseries[] | {name: .labels.mode, values: [.values[-5:][]]}' | head -20
echo ""
echo "=== Server Metrics (Disk I/O last 1h) ==="
hcloud server metrics "$SERVER_ID" --type disk --start "$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" --end "$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o json 2>/dev/null | jq '.metrics.timeseries[] | {name: .labels | to_entries | map(.value) | join("-"), values_tail: [.values[-3:][]]}' | head -15
echo ""
echo "=== Server Metrics (Network last 1h) ==="
hcloud server metrics "$SERVER_ID" --type network --start "$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" --end "$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o json 2>/dev/null | jq '.metrics.timeseries[] | {name: .labels | to_entries | map(.value) | join("-"), values_tail: [.values[-3:][]]}' | head -15
Output Format
ID NAME STATUS TYPE CORES MEMORY DATACENTER IP
123456 web-01 running cx21 2 4GB fsn1-dc14 1.2.3.4
Safety Rules
- Use read-only commands:
list, describe, metrics
- Never run
delete, shutdown, rebuild without explicit user confirmation
- Use
-o json with jq for detailed output, -o columns= for summaries
- Limit output with
| head -N to stay under 50 lines
Anti-Hallucination Rules
- NEVER assume resource names — always discover via CLI/API in Phase 1 before referencing in Phase 2.
- NEVER fabricate metric names or dimensions — verify against the service documentation or
--help output.
- NEVER mix CLI commands between service versions — confirm which version/API you are targeting.
- ALWAYS use the discovery → verify → analyze chain — every resource referenced must have been discovered first.
- ALWAYS handle empty results gracefully — an empty response is valid data, not an error to retry.
Counter-Rationalizations
| Shortcut |
Counter |
Why |
| "I'll skip discovery and check known resources" |
Always run Phase 1 discovery first |
Resource names change, new resources appear — assumed names cause errors |
| "The user only asked for a quick check" |
Follow the full discovery → analysis flow |
Quick checks miss critical issues; structured analysis catches silent failures |
| "Default configuration is probably fine" |
Audit configuration explicitly |
Defaults often leave logging, security, and optimization features disabled |
| "Metrics aren't needed for this" |
Always check relevant metrics when available |
API/CLI responses show current state; metrics reveal trends and intermittent issues |
| "I don't have access to that" |
Try the command and report the actual error |
Assumed permission failures prevent useful investigation; actual errors are informative |
1---2name: managing-hetzner-cloud3description: |4 Use when working with Hetzner Cloud — hetzner Cloud deep-dive management via5 the hcloud CLI. Covers server types, pricing, placement groups, certificates,6 primary IPs, and detailed server metrics. Use for detailed Hetzner Cloud7 analysis beyond basic server listing.8connection_type: hetzner-cloud9preload: false10metadata:11 source: https://skillmd.com/skills/cloudthinker-ai/managing-hetzner-cloud12---1314# Managing Hetzner Cloud (Deep Dive)1516Deep-dive Hetzner Cloud management using the `hcloud` CLI for detailed analysis.1718## MANDATORY: Discovery-First Pattern1920**Always discover available resources before performing analysis.**2122### Phase 1: Discovery2324```bash25#!/bin/bash2627echo "=== Server Types (Available) ==="28hcloud server-type list -o columns=id,name,description,cores,memory,disk,storage_type 2>/dev/null | head -202930echo ""31echo "=== Placement Groups ==="32hcloud placement-group list -o columns=id,name,type,servers 2>/dev/null | head -103334echo ""35echo "=== Primary IPs ==="36hcloud primary-ip list -o columns=id,name,type,ip,datacenter,assignee_id,auto_delete 2>/dev/null | head -103738echo ""39echo "=== Certificates ==="40hcloud certificate list -o columns=id,name,type,domain_names,not_valid_after 2>/dev/null | head -104142echo ""43echo "=== Images ==="44hcloud image list --type system -o columns=id,name,description,os_flavor,os_version,disk_size 2>/dev/null | head -154546echo ""47echo "=== Snapshots ==="48hcloud image list --type snapshot -o columns=id,description,created,image_size,disk_size 2>/dev/null | head -104950echo ""51echo "=== Backups ==="52hcloud image list --type backup -o columns=id,description,created,image_size,created_from_name 2>/dev/null | head -1053```5455### Phase 2: Analysis5657```bash58#!/bin/bash5960SERVER_ID="${1:?Server ID required}"6162echo "=== Server Details ==="63hcloud server describe "$SERVER_ID" -o json 2>/dev/null | jq '{64 id, name, status,65 server_type: .server_type.name,66 cores: .server_type.cores,67 memory: .server_type.memory,68 disk: .server_type.disk,69 datacenter: .datacenter.name,70 location: .datacenter.location.city,71 public_ipv4: .public_net.ipv4.ip,72 public_ipv6: .public_net.ipv6.ip,73 private_nets: [.private_net[] | {network: .network, ip: .ip}],74 image: .image.name,75 iso: .iso,76 rescue_enabled: .rescue_enabled,77 locked: .locked,78 protection: .protection,79 labels: .labels,80 created: .created81}'8283echo ""84echo "=== Server Metrics (CPU last 1h) ==="85hcloud server metrics "$SERVER_ID" --type cpu --start "$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" --end "$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o json 2>/dev/null | jq '.metrics.timeseries[] | {name: .labels.mode, values: [.values[-5:][]]}' | head -208687echo ""88echo "=== Server Metrics (Disk I/O last 1h) ==="89hcloud server metrics "$SERVER_ID" --type disk --start "$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" --end "$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o json 2>/dev/null | jq '.metrics.timeseries[] | {name: .labels | to_entries | map(.value) | join("-"), values_tail: [.values[-3:][]]}' | head -159091echo ""92echo "=== Server Metrics (Network last 1h) ==="93hcloud server metrics "$SERVER_ID" --type network --start "$(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -d '1 hour ago' +%Y-%m-%dT%H:%M:%SZ)" --end "$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o json 2>/dev/null | jq '.metrics.timeseries[] | {name: .labels | to_entries | map(.value) | join("-"), values_tail: [.values[-3:][]]}' | head -1594```9596## Output Format9798```99ID NAME STATUS TYPE CORES MEMORY DATACENTER IP100123456 web-01 running cx21 2 4GB fsn1-dc14 1.2.3.4101```102103## Safety Rules104- Use read-only commands: `list`, `describe`, `metrics`105- Never run `delete`, `shutdown`, `rebuild` without explicit user confirmation106- Use `-o json` with jq for detailed output, `-o columns=` for summaries107- Limit output with `| head -N` to stay under 50 lines108109## Anti-Hallucination Rules1101111. **NEVER assume resource names** — always discover via CLI/API in Phase 1 before referencing in Phase 2.1122. **NEVER fabricate metric names or dimensions** — verify against the service documentation or `--help` output.1133. **NEVER mix CLI commands between service versions** — confirm which version/API you are targeting.1144. **ALWAYS use the discovery → verify → analyze chain** — every resource referenced must have been discovered first.1155. **ALWAYS handle empty results gracefully** — an empty response is valid data, not an error to retry.116117## Counter-Rationalizations118119| Shortcut | Counter | Why |120|----------|---------|-----|121| "I'll skip discovery and check known resources" | Always run Phase 1 discovery first | Resource names change, new resources appear — assumed names cause errors |122| "The user only asked for a quick check" | Follow the full discovery → analysis flow | Quick checks miss critical issues; structured analysis catches silent failures |123| "Default configuration is probably fine" | Audit configuration explicitly | Defaults often leave logging, security, and optimization features disabled |124| "Metrics aren't needed for this" | Always check relevant metrics when available | API/CLI responses show current state; metrics reveal trends and intermittent issues |125| "I don't have access to that" | Try the command and report the actual error | Assumed permission failures prevent useful investigation; actual errors are informative |126