Skip to main content

System Facts

Agents automatically collect system facts — typed properties about the host they run on — and publish them to a dedicated NATS KV bucket. Facts power two features: the agent get display and fact references (@fact.*) that let you inject live system values into job parameters.

What Gets Collected

Facts are gathered from providers every 60 seconds (configurable via agent.facts.interval) and stored in the agent-facts KV bucket with a 5-minute TTL.

FactDescriptionExample Value
ArchitectureCPU architectureamd64, arm64
Kernel VersionOS kernel version string6.8.0-51-generic
FQDNFully qualified domain nameweb-01.example.com
CPU CountNumber of logical CPUs8
Service ManagerInit systemsystemd, launchd
Package ManagerSystem package managerapt, brew
InterfacesNetwork interfaces with IPv4, IPv6, MAC, familySee below
Primary InterfaceInterface name of the default routeeth0, en0
RoutesIP routing table entriesSee below

Network Interfaces

Each interface entry includes:

  • Name — interface name (e.g., eth0, en0)
  • IPv4 — IPv4 address (if assigned)
  • IPv6 — IPv6 address (if assigned)
  • MAC — hardware address
  • Familyinet, inet6, or dual

Only non-loopback, up interfaces are included.

Routes

Each route entry includes:

  • Destination — target network or default / 0.0.0.0
  • Gateway — next-hop address
  • Interface — outgoing interface name
  • Mask — CIDR mask (Linux only, e.g., /24)
  • Metric — route metric (Linux only)
  • Flags — route flags

Fact References (@fact.*)

Fact references let you use live system values in job parameters. When an agent processes a job, it replaces any @fact.* token in the request data with the corresponding value from its cached facts. This happens transparently — the CLI and API send the literal @fact.* string, and the agent resolves it before executing the operation.

Available References

ReferenceResolves ToExample Value
@fact.hostnameAgent's hostnameweb-01
@fact.archCPU architectureamd64
@fact.kernelKernel version6.8.0-51-generic
@fact.fqdnFully qualified hostnameweb-01.example.com
@fact.interface.primaryDefault route interfaceeth0
@fact.custom.<key>Custom fact value(user-defined)

Usage Examples

Query DNS configuration on the primary network interface:

osapi client node network dns get \
--interface-name @fact.interface.primary

Echo the hostname on the remote host:

osapi client node command exec \
--command echo --args "@fact.hostname"

Use multiple references in a single command:

osapi client node command exec \
--command echo \
--args "@fact.interface.primary on @fact.hostname"

Use fact references with broadcast targeting:

osapi client node command exec \
--command ip --args "addr,show,dev,@fact.interface.primary" \
--target _all

How It Works

  1. The CLI sends the literal @fact.* string in the job request data
  2. The API server publishes the job to NATS as-is
  3. The agent receives the job and checks the request data for @fact.* tokens
  4. Each token is resolved against the agent's locally cached facts
  5. The resolved data is passed to the provider for execution

Because resolution happens agent-side, fact references work correctly with broadcast (_all) and label-based routing — each agent substitutes its own values. For example, @fact.interface.primary resolves to eth0 on one host and en0 on another.

If a referenced fact is not available (e.g., the agent hasn't collected facts yet, or the fact key doesn't exist), the job fails with an error describing which reference could not be resolved.

Supported Contexts

Fact references work in any string value within job request data:

  • Command arguments--args "@fact.hostname"
  • DNS interface name--interface-name @fact.interface.primary
  • Nested values — references inside maps and arrays are resolved recursively

Non-string values (numbers, booleans) are not modified.

Viewing Facts

Use agent get to see the full facts for a specific agent:

osapi client agent get --hostname web-01

The output includes architecture, kernel, FQDN, CPUs, service/package manager, network interfaces, and routes. Use --json for the complete structured data.

Configuration

KeyDescriptionDefault
agent.facts.intervalHow often facts are collected60s
nats.facts.bucketKV bucket name for facts storageagent-facts
nats.facts.ttlTTL for facts entries5m
nats.facts.storageStorage backend (file or memory)file

See Configuration for the full reference.

Platform Support

Facts are collected using platform-specific providers. All facts are available on both Linux and macOS:

FactLinux ProvidermacOS Provider
Architecturegopsutilgopsutil
Kernel Versiongopsutilgopsutil
FQDNgopsutilgopsutil
CPU Countgopsutilgopsutil
Service Managergopsutilgopsutil
Package Managergopsutilgopsutil
Interfacesnet.Interfaces (stdlib)net.Interfaces (stdlib)
Primary Interface/proc/net/route parsingnetstat -rn parsing
Routes/proc/net/route parsingnetstat -rn parsing

Provider errors are non-fatal — if a provider fails, the agent still publishes whatever facts it could gather. This means @fact.interface.primary may be unavailable if route collection fails, but @fact.hostname and @fact.arch will still work.