Adapters

Where metrics go · Prometheus, statsd, file, stdout, webhook.

An adapter exports metrics to an external system: a /metrics endpoint, statsd, a file, a webhook.

Anatomy

[[adapters]]
name   = "scrape"          # required handle
kind   = "prometheus"      # defaults to `name` if omitted
filter = ""                # nanook-expr filter on metric name / labels
plugin = ""                # explicit plugin crate (rare)
[adapters.opts]
# kind-specific options

filter scopes what each adapter sees. Two adapters can run side-by-side, one shipping CPU stats, the other HTTP probes.

[[adapters]]
name   = "metrics"
kind   = "prometheus"
filter = 'name like "cpu.*" || name like "mem.*"'
[adapters.opts]
port = 9090

[[adapters]]
name   = "http-log"
kind   = "file"
filter = 'name like "http.*"'
[adapters.opts]
path = "/var/log/nanook/http.jsonl"

Built-in kinds

KindCargo featureWhat
prometheusadapter-prometheusServe a /metrics endpoint for scrapes
statsdadapter-statsdUDP push to a vanilla statsd receiver
dogstatsdadapter-statsdUDP push to a Datadog dogstatsd receiver (label-aware)
fileadapter-fileAppend JSONL or CSV to a file
stdoutadapter-stdoutPrint to stdout, useful for debugging
webhookadapter-webhookPOST batches to an HTTP endpoint
pulseadapter-pulseServe nanook's native binary frames over HTTP

Drop adapters you do not need with --no-default-features on nanook-cli and an explicit feature list. See Collectors → Slim builds for the pattern.

Filtering tricks

The filter DSL has name, src, and label keys as pseudo-fields:

# only the api collector's metrics
filter = 'src is "api"'

# everything except debug
filter = 'name not like "*.debug"'

# specific interfaces
filter = 'iface like "eth*"'

Writing your own

An adapter is a Rust crate that implements the Adapter trait and ships as a cdylib. See Plugins.