Labels and views
Labels and selectors let you target objects like “everything in prod” as one command, without a separate grouping construct to keep in sync with reality.
Labels are the model, not hostgroups
Section titled “Labels are the model, not hostgroups”Hosts, services and contacts carry key/value labels:
hosts: web: { address: "10.0.0.1" check: {type: "icmp", host: "10.0.0.1"} labels: {env: "prod", role: "web"} services: api: { check: {type: "tcp", address: "10.0.0.1:443"} labels: {env: "prod", tier: "backend"} }}Labels live in the core; groups don’t. There’s no native “hostgroup” object to define and maintain separately from the objects it names — membership is just whichever objects happen to share a label. Nagios hostgroups translate to labels automatically when you import (see From Nagios).
Key and value constraints
Section titled “Key and value constraints”Keys and values are each constrained by their own regex, enforced at the CUE level so a malformed label fails validation with a field-level error rather than a runtime one:
- Key —
=~"^[a-z][a-z0-9_.-]*$": lowercase-only, so a label never reads like a#Varsmacro name (uppercase-enforced, and a completely different thing). - Value —
=~"^[a-zA-Z0-9][a-zA-Z0-9_.:/-]*$".
labels: {Env: "prod"} // rejected: uppercase keySelectors
Section titled “Selectors”A selector is comma-separated key=value pairs, matched as AND:
env=prod, team=redesAny command that targets objects — acknowledge, downtime — accepts either
one explicit object or a selector matching many at once. “Downtime every
service tagged team=redes” is one ScheduleDowntime call with a
selector target, not a loop over object names.
Saved views
Section titled “Saved views”A view is a name bound to a selector — never to a static membership list, so it can’t silently go stale as objects come and go:
views: { prod: selector: "env=prod" "Web Servers": { selector: "hostgroup.web-servers" description: "Nagios hostgroup \"Web Servers\"" }}The map key is the display name, deliberately unconstrained (spaces and
uppercase allowed) because it’s never parsed — it’s exactly what an
operator wrote, or exactly what a Nagios group’s alias was before import.
description is free text, defaulting to empty. The dashboard’s #/groups
page lists every saved view alongside a live member count; see
Dashboard.