Monitoring
All three binaries, the server, the agent and the CSI
provider, report metrics the same way: OpenTelemetry
instruments, pushed over OTLP or scraped by Prometheus, chosen by their
config’s [metrics] section and read at startup. Attributes are small
fixed sets (an operation, a result, a reason): never a secret’s path, an
identity, a pod, a file name or a value.
Choosing an exporter
Section titled “Choosing an exporter”[metrics] exporter is one of:
otlp: pushed over OTLP/gRPC to the collectorOTEL_EXPORTER_OTLP_ENDPOINT(orOTEL_EXPORTER_OTLP_METRICS_ENDPOINT) names; without it, the binary refuses to start. The other standard variables apply:OTEL_METRIC_EXPORT_INTERVAL(default 60 s),OTEL_RESOURCE_ATTRIBUTES, andOTEL_SERVICE_NAME(default the binary’s name,ferritor-server,ferritor-agentorferritor-csi-provider).https://(or no scheme, unlessOTEL_EXPORTER_OTLP_INSECURE=true) is TLS with the public roots, plusOTEL_EXPORTER_OTLP_CERTIFICATEfor a private CA andOTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE/_CLIENT_KEYfor mTLS;http://is plaintext, for a collector on the same host. The last export is flushed at exit.prometheus:GET /metricsin the text format, on a listener of its own (listen_addr), never a binary’s main one. TheOTEL_*variables are ignored then (a set endpoint warns).none: off.
Without exporter, it’s OTLP if OTEL_EXPORTER_OTLP_METRICS_ENDPOINT or
OTEL_EXPORTER_OTLP_ENDPOINT is set (and not empty), off if neither is.
One exporter at a time.
The Prometheus listener, per binary:
Default listen_addr |
Off loopback | |
|---|---|---|
| Server | 127.0.0.1:9464 |
TLS with the server’s certificate (secured mode; renewed with it on SIGHUP), with client_ca a scraper must present a certificate from that CA; plaintext only with tls = false |
| Agent | 127.0.0.1:9465 |
plaintext only, with tls = false said (it has no certificate to serve with) |
| CSI provider | 127.0.0.1:9466 |
the same as the agent’s |
On a loopback address the listener is plaintext and answers only requests
addressed to loopback (localhost or a loopback IP), against DNS
rebinding: a web page that gets its own name resolved to 127.0.0.1 is
refused (421). Plaintext off loopback warns at startup. The server’s
answers while sealed too, and a scrape is no request there: no audit entry,
no rate limit, not counted in ferritor.in_flight. Settings:
server, agent,
CSI provider.
[metrics]exporter = "prometheus"listen_addr = "127.0.0.1:9464"curl -s http://127.0.0.1:9464/metrics | grep ferritor_sealedNames follow OpenTelemetry’s Prometheus conventions: dots become
underscores, a unit adds its suffix (_seconds), a counter ends in
_total, and a histogram is its _bucket, _sum and _count series. The
tables below give both names; tests hold each to what a scrape returns.
Request durations are bucketed from 1 ms to 10 s.
The server
Section titled “The server”The server’s wait for a slot under the server-wide cap is bucketed from 0 to 10 s.
| Instrument | Prometheus | Kind | Attributes |
|---|---|---|---|
ferritor.secret.requests |
ferritor_secret_requests_total |
counter | operation, result |
ferritor.secret.request.duration |
ferritor_secret_request_duration_seconds |
histogram (s) | operation, result |
ferritor.admin.outcomes |
ferritor_admin_outcomes_total |
counter | operation, result (succeeded, failed, unknown) |
ferritor.authorization.decisions |
ferritor_authorization_decisions_total |
counter | action, decision (allowed, denied, sealed, unverified) |
ferritor.audit.failures |
ferritor_audit_failures_total |
counter | kind (refused, lost) |
ferritor.versions.trimmed |
ferritor_versions_trimmed_total |
counter | |
ferritor.versions.purged |
ferritor_versions_purged_total |
counter | |
ferritor.deks.rewrapped |
ferritor_deks_rewrapped_total |
counter | |
ferritor.tls.handshake.failures |
ferritor_tls_handshake_failures_total |
counter | listener (api, exchange, metrics: a scraper without the right certificate counts here, not as an API client), reason (failed, timed_out) |
ferritor.rate_limit.refused |
ferritor_rate_limit_refused_total |
counter | limit (rate, in_flight, denied, unauthenticated; exchanges: a token exchange refused, too many for its identity; exchange_refused: a refused exchange’s audit entry left out; server: no slot under the server-wide cap in time) |
ferritor.identity.exchanges |
ferritor_identity_exchanges_total |
counter | issuer (a configured issuer’s name, or unknown), result (issued, refused, unavailable, rate_limited) |
ferritor.rate_limit.waited |
ferritor_rate_limit_waited_seconds |
histogram (s) | the wait for a slot under the server-wide cap |
ferritor.reloads |
ferritor_reloads_total |
counter | kind (policy, certificate, crl, keyring, policy_store, identity, audit_log: the file’s reopen at SIGHUP), result (policy_store: changed, unchanged, failed, integrity, rollback, recovered; counted on every attempt, while a failure is logged and audited only when it starts, changes or ends) |
ferritor.policy.revision |
ferritor_policy_revision |
gauge | the stored policies’ verified revision in force; absent unless one is |
ferritor.policies |
ferritor_policies |
gauge | stored policies in force; absent unless verified |
ferritor.audit.queue.depth |
ferritor_audit_queue_depth |
gauge | entries waiting for the writer |
ferritor.in_flight |
ferritor_in_flight |
gauge | calls in flight, every one (exempt admin calls too, which the server-wide cap doesn’t count) |
ferritor.sealed |
ferritor_sealed |
gauge | 1 sealed, 0 unsealed |
ferritor.namespaces |
ferritor_namespaces |
gauge | namespaces this server holds KEKs of; absent while sealed (a count, never names) |
ferritor.seal.auto_unseal |
ferritor_seal_auto_unseal_total |
counter | result: ok, kms_unavailable, denied, mismatch, root_commitment, below_floor, no_wrap, held, failed (see key management) |
ferritor.seal.hold_pending |
ferritor_seal_hold_pending |
gauge | auto-unseal hold (or release) writes being retried after a seal; 0 normally |
ferritor.seal.floor_pending |
ferritor_seal_floor_pending |
gauge | root-generation floor raises being retried after an init or a rekey; 0 normally (see key management) |
ferritor.kek.vanished |
ferritor_kek_vanished |
gauge | KEKs held for reading only because the keys database lost them; 0 normally (see high availability) |
ferritor.server_certificate.expiry |
ferritor_server_certificate_expiry_seconds |
gauge (unix s) | secured mode |
ferritor.tls.crl.next_update |
ferritor_tls_crl_next_update_seconds |
gauge (unix s) | the earliest nextUpdate of the CRLs in force |
ferritor.watch.streams |
ferritor_watch_streams |
gauge | watch streams open (at most 4,096 per server) |
ferritor.watch.feed.live |
ferritor_watch_feed_live |
gauge | 1 while the change feed polls the data database, 0 while it can’t |
ferritor.watch.feed.held_back |
ferritor_watch_feed_held_back_seconds |
gauge (s) | how long one open transaction has held the change feed back (below); 0 normally |
ferritor.watch.resyncs |
ferritor_watch_resyncs_total |
counter | reason (too_many, restarted: every stream told at once; lagged: one stream fell behind) |
ferritor.schedule.runs |
ferritor_schedule_runs_total |
counter | task (purge, rewrap), result (ok, failed, interrupted, lost): the scheduled runs this server made |
ferritor.schedule.run.duration |
ferritor_schedule_run_duration_seconds |
histogram (s) | task |
ferritor.schedule.last_success |
ferritor_schedule_last_success_seconds |
gauge (unix s) | task: when a run, on any server, last finished everything; from the shared schedule, so every server reports the same; absent before the first |
ferritor.schedule.paused |
ferritor_schedule_paused |
gauge | task: 1 paused for every server (ferritor schedule pause), 0 not |
ferritor.secrets.rotation_overdue |
ferritor_secrets_rotation_overdue |
gauge | secrets with the rotation flag (ferritor.rotation=true) whose current version is older than rotation_max_age_days (below) |
ferritor.secrets.rotation_due_soon |
ferritor_secrets_rotation_due_soon |
gauge | the same, within rotation_warn_days of it |
ferritor.keks.rotation_overdue |
ferritor_keks_rotation_overdue |
gauge | namespaces whose active KEK is older than kek_max_age_days |
ferritor.keks.rotation_due_soon |
ferritor_keks_rotation_due_soon |
gauge | the same, within rotation_warn_days of it |
ferritor.root_key.rotation_overdue |
ferritor_root_key_rotation_overdue |
gauge | 1 if the root key is older than root_key_max_age_days since its last rekey (or init) |
ferritor.root_key.rotation_due_soon |
ferritor_root_key_rotation_due_soon |
gauge | 1 within rotation_warn_days of it |
Rotation reminders. The six rotation_* gauges count, server-wide and
with no attribute (never a path or a namespace), what’s past its maximum age
and what’s within rotation_warn_days of it
(configuration). A reminder only: nothing is
refused for age. Each server counts every 5 minutes, so they move by the day
and every server reports the same numbers: alert on the max() across
servers. Each is absent until a server has counted once. A secret’s age is
its current version’s (a restore of an older version counts from that
version’s creation), only for secrets with the flag. A KEK’s is the active
KEK’s: a rotation makes a new active KEK at once, though rows stay on the
retired one until a rewrap (ferritor rewrap), which these gauges don’t
see. There’s no DEK gauge: every put makes a new DEK, and a rewrap keeps it,
so a DEK’s age is its version’s. ferritor metadata get gives a flagged
secret’s due date.
What to alert on
Section titled “What to alert on”ferritor_sealedat 1: nothing can be read until it’s unsealed.ferritor_seal_hold_pendingabove 0: a sealed server a restart could unseal again.ferritor_seal_auto_unseal_totalwith any result butokandheld: a server that can’t unseal itself;root_commitmentandbelow_floorneed a person (key management).ferritor_kek_vanishedabove 0: urgent, see high availability.max(ferritor_secrets_rotation_overdue) > 0,max(ferritor_keks_rotation_overdue) > 0andmax(ferritor_root_key_rotation_overdue) > 0: something is past its rotation’s maximum age, a ticket rather than a page; thedue_soongauges as an earlier warning. Rotate a secret with a new version, a namespace’s KEK withferritor rotate, the root key withferritor rekey(key management).time() - max by (task) (ferritor_schedule_last_success_seconds)above two intervals (two days for purge, two hours for rewrap, by default): a scheduled task hasn’t finished in that long (every server sealed, a failing run:ferritor statusshows the last result, the logs and the audit log why). Every server reports the same time, so the alert works whichever is scraped. The gauge is absent until a task’s first success, so a deployment whose runs have never succeeded needs its own alert:absent(ferritor_schedule_last_success_seconds{task="purge"})(andtask="rewrap") for longer than an interval after the deployment started, or anyferritor_schedule_runs_totalwith aresultbutokthat keeps rising. Andmax(ferritor_schedule_paused) > 0held for longer than an incident should take: a pause someone forgot.ferritor_audit_queue_depthrising (the audit log’s file stalling, before requests are refused), anyferritor_audit_failures_total, andferritor_reloads_total{kind="audit_log",result="failed"}(a reopen that couldn’t open the file: requests are refused until it can).- The two expiry gauges,
ferritor_server_certificate_expiry_secondsandferritor_tls_crl_next_update_seconds, getting near. ferritor_policy_revisiondiffering between servers for longer thanpolicy_refresh_secs: a rollback of the stored policies, one server still having the newer set.ferritor_reloads_totalwithkind="policy_store"andresultintegrityorrollback: the stored policies don’t verify (see policy); re-apply them from their source of truth withferritor policy apply --prune, and find out who changed the keys database.ferritor_watch_feed_liveat 0 for more than a few seconds: the data database unreachable for the change feed, so no new watch streams, and the agents and providers fall back to their intervals.ferritor_watch_streamsnear 4,096: new streams refused withWATCH_FULL(an identity’s own cap, 256 by default, ismax_watch_streamsin configuration).ferritor_watch_feed_held_back_secondsabove a few minutes: a transaction left open.- The rate limits: operations.
The process is closed to its own user. The server marks itself
undumpable at startup (see security), so /proc/<pid>/
belongs to root: a monitoring agent that reads it as an unprivileged user
(a process exporter, some APM agents) gets nothing for ferritor, and neither
do debuggers and profilers. Use the metrics above, or run such an agent as
root. There are no core dumps either: a crash leaves its panic message and
backtrace on stderr, in the journal.
The agent
Section titled “The agent”| Instrument | Prometheus | Kind | Attributes |
|---|---|---|---|
ferritor.agent.rounds |
ferritor_agent_rounds_total |
counter | result (ok; transient: stopped by a transient refusal) |
ferritor.agent.round.duration |
ferritor_agent_round_duration_seconds |
histogram (s) | result; the round’s writes, notifications and status files included |
ferritor.agent.calls |
ferritor_agent_calls_total |
counter | call (get, list, watch), result (ok, permission_denied, not_found, invalid, transient) |
ferritor.agent.writes |
ferritor_agent_writes_total |
counter | result (ok, failed): sets of files swapped in |
ferritor.agent.notifications |
ferritor_agent_notifications_total |
counter | kind (signal, command), result (ok, failed, timed_out: a command still running after 60 s). A signal counts once per process it’s sent to |
ferritor.agent.exchanges |
ferritor_agent_exchanges_total |
counter | result (ok, failed): with token_file |
ferritor.agent.watch.events |
ferritor_agent_watch_events_total |
counter | event (ready, changed, resync, ended, failed) |
ferritor.agent.config.reloads |
ferritor_agent_config_reloads_total |
counter | result (ok; failed: the new config didn’t load or an output couldn’t be opened, the running one kept): its file changed, or SIGHUP |
ferritor.agent.secrets |
ferritor_agent_secrets |
gauge | One per secret an output reads (files and templates’ inputs of an output with the same path, version and detect count once). state (current: readable, its value in every file using it; refused: for good, its file per on_revoked; pending: neither yet, not read or not written: the first set waiting for a required secret, a write that failed) |
ferritor.agent.templates |
ferritor_agent_templates |
gauge | One per [[output.template]] and per [[exec.env]] variable (exec). state (current: rendered from its inputs’ latest values; stale: an input refused for good, its last value kept, on_revoked = "keep"; removed: an input refused for good and its file or variable gone, or never written; pending: an input not read yet, or not written yet; failed: a filter refused an input’s value, or the rendering was too long, its file or variable left out) |
ferritor.agent.last_success |
ferritor_agent_last_success_seconds |
gauge (unix s) | when a round last succeeded; absent before the first |
ferritor.agent.watch.ready |
ferritor_agent_watch_ready |
gauge | 1 while a ready stream covers every watched secret |
ferritor.agent.certificate.expiry |
ferritor_agent_certificate_expiry_seconds |
gauge (unix s) | the client certificate in use: from its file, or as exchanged |
Worth an alert: time() - ferritor_agent_last_success_seconds past a few
intervals (the files have stopped following the server; while a watch
stream is ready rounds stretch to ten intervals, at most ten minutes, so
allow for that: 15 minutes is a fair default), any
ferritor_agent_secrets{state="refused"} > 0 or
ferritor_agent_secrets{state="pending"} > 0 that lasts, any ferritor_agent_templates{state="failed"} > 0 (both gauges
show every state, zero included, so say > 0), a failed reload
(increase(ferritor_agent_config_reloads_total{result="failed"}[1h]) > 0:
an edit that isn’t in force, the log says why), a
ferritor_agent_certificate_expiry_seconds near (a certificate from files
nobody renews).
The CSI provider
Section titled “The CSI provider”| Instrument | Prometheus | Kind | Attributes |
|---|---|---|---|
ferritor.csi.mounts |
ferritor_csi_mounts_total |
counter | result (ok, refused, failed: transient, the volume as it is; invalid: the SecretProviderClass) |
ferritor.csi.mount.duration |
ferritor_csi_mount_duration_seconds |
histogram (s) | result |
ferritor.csi.calls |
ferritor_csi_calls_total |
counter | call (get, list, watch), result (ok, permission_denied, not_found, invalid, transient) |
ferritor.csi.from_memory |
ferritor_csi_from_memory_total |
counter | kind (read: shared, vouched for by a watch, or the volume’s own value at the version its listing shows; listing: shared, or vouched for by a watch; refusal: remembered, backing off): answered without the server |
ferritor.csi.exchanges |
ferritor_csi_exchanges_total |
counter | result (issued, refused, failed): pods’ tokens, renewals included |
ferritor.csi.watch.events |
ferritor_csi_watch_events_total |
counter | event (ready, changed, resync, ended, failed) |
ferritor.csi.identities |
ferritor_csi_identities |
gauge | identities with a certificate on this node |
ferritor.csi.volumes |
ferritor_csi_volumes |
gauge | volumes remembered |
ferritor.csi.watch.streams |
ferritor_csi_watch_streams |
gauge | identities’ watch streams open and ready |
Worth an alert: ferritor_csi_mounts_total{result="failed"} rising (pods
waiting on a server they can’t reach, or a sealed one), and
{result="refused"} after a policy change.
Scraping in Kubernetes
Section titled “Scraping in Kubernetes”With kube-prometheus-stack (the Prometheus Operator):
- The server off loopback serves TLS, and only scrapers with a
certificate from a CA of your own should read it: the scrapers’ CA, the
ServiceMonitorand Prometheus’s certificate are in Kubernetes. - Agents and providers serve plaintext: listen on
0.0.0.0withtls = false, name the container’s port, and select the pods with aPodMonitor. Anyone who reaches the pod’s port reads the metrics (counts and results, nothing of a value), so keep it to the cluster’s network.
[metrics]exporter = "prometheus"listen_addr = "0.0.0.0:9465" # the provider's: 9466tls = false# The agent's container (a sidecar), or the provider's DaemonSet:ports: [{name: metrics, containerPort: 9465}]# and the pod template's labels:labels: {app: billing-worker, ferritor-metrics: agent} # ferritor-metrics: csi-provider---apiVersion: monitoring.coreos.com/v1kind: PodMonitormetadata: name: ferritor namespace: monitoring labels: {release: monitoring} # kube-prometheus-stack's release name: it selects by itspec: namespaceSelector: {any: true} selector: matchExpressions: [{key: ferritor-metrics, operator: Exists}] podMetricsEndpoints: - port: metrics relabelings: - {sourceLabels: [__meta_kubernetes_pod_label_ferritor_metrics], targetLabel: component} - {sourceLabels: [__meta_kubernetes_pod_label_app], targetLabel: app}The component and app labels are what the dashboards below filter by.
kube-prometheus-stack picks up only the monitors labelled with its
release’s name (monitoring here); installed with
prometheus.prometheusSpec.podMonitorSelectorNilUsesHelmValues=false, it
picks up every one.
Dashboards
Section titled “Dashboards”Three Grafana dashboards, one per binary, are in the repository’s
deploy/grafana/
(a test holds every metric they query to the tables above):
ferritor-server.json: the seal state, namespaces and policies, secret requests by operation and result with their latency, authorization decisions and denials, rate limits, token exchanges, the audit queue, reloads and housekeeping.ferritor-agent.json: per pod, how long since its last good round, its secrets by state, its watch and its certificate’s expiry; rounds, calls to the server, writes, exchanges and notifications; templates by state and config reloads.ferritor-csi.json: mounts by result and their latency, the calls to the server behind them and what memory answered instead, exchanges, watch streams, identities and volumes.



Each asks for its Prometheus data source when imported (Dashboards, New,
Import, upload the file), and filters by pod, and the agent’s also by
namespace and app (the labels the PodMonitor above sets).
kube-prometheus-stack’s Grafana loads them from ConfigMaps labelled
grafana_dashboard: "1":
for d in server agent csi; do kubectl -n monitoring create configmap ferritor-dashboard-$d \ --from-file=deploy/grafana/ferritor-$d.json kubectl -n monitoring label configmap ferritor-dashboard-$d grafana_dashboard=1done