CUE in practice
This page walks through building a real config against jaque’s schema, with snippets you can copy and adapt.
The smallest config
Section titled “The smallest config”hosts: gw: { address: "192.168.1.1" check: {type: "icmp", host: address}}One host, ICMP checked every 60 seconds (#Schedule’s default). host: address reuses the field you just set two lines up — CUE resolves
references within the same struct, so you’re not retyping the IP.
A host with a service
Section titled “A host with a service”hosts: gw: { address: "192.168.1.1" check: {type: "icmp", host: "192.168.1.1"} services: web: check: {type: "http", url: "http://192.168.1.1/"}}Every service under a host is checked independently, with its own
#Schedule — a service doesn’t inherit its host’s check_interval
unless you make it.
A shared template
Section titled “A shared template”Ten devices of the same kind shouldn’t repeat their check config ten
times: anchor a partial struct on #Host (or #Check) and unify it at
each use site. See Why CUE for the
#CastDevice example and why anchoring on the schema, not a bare struct,
is what makes this safe to do at scale.
Contacts, a policy, and an escalation
Section titled “Contacts, a policy, and an escalation”contacts: { oncall_hook: {type: "webhook", url: "https://hooks.example.com/oncall"}}
notifications: business_hours: { period: [ {weekday: "monday", start: "09:00", end: "17:00"}, ] levels: [ {contacts: ["alice"], threshold: 3, renotify_interval: "30m"}, {contacts: ["oncall_hook"], renotify_interval: "10m"}, ]}
hosts: gw: { address: "192.168.1.1" check: {type: "icmp", host: "192.168.1.1"} notification: "business_hours"}Full detail — every contact type, escalation semantics, windows — is in Contacts and policies and Escalations and windows.
Labels and views
Section titled “Labels and views”hosts: web: { address: "10.0.0.1" check: {type: "icmp", host: "10.0.0.1"} labels: {env: "prod", role: "web"}}
views: prod: selector: "env=prod"See Labels and views for selector grammar and what a saved view actually is.
zone defaults to "default" on a host; a service’s zone defaults to
"", which inherits the host’s:
hosts: gw: {zone: "eu-west"}services: web: {} // inherits "eu-west"Validating a config
Section titled “Validating a config”There’s no separate jaque validate — loading is validating:
jaque -config yourfile.cueValidation happens in two phases and fails differently depending on which one catches the problem — see Why CUE for the distinction between a schema-constraint failure (unknown field, wrong type) and a concretion failure (a value left unresolved). Either way, the error names the field, not just “config invalid”.