Documentation
¶
Overview ¶
Package metrics provides the lightweight Prometheus text-format metrics types and the Store that aggregates them for the registry server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultDurationBuckets = []float64{
0.0001, 0.00025, 0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0,
}
DefaultDurationBuckets are the default histogram buckets for request duration (seconds).
var SaveDurationBuckets = []float64{
0.1, 0.25, 0.5, 1, 1.5, 2, 3, 5, 10, 30, 60,
}
SaveDurationBuckets bracket the typical flushSave wall time for a production-sized snapshot. At 220k+ nodes we see ~1.5 s steady-state and up to ~5 s under heavy concurrent load; the long buckets catch the occasional cliff so an operator can spot it.
Functions ¶
func FormatFloat ¶
FormatFloat formats a float64 for Prometheus output. Integers are printed without decimal point for cleaner output.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a monotonically increasing atomic counter.
type CounterVec ¶
type CounterVec struct {
// contains filtered or unexported fields
}
CounterVec is a set of Counters keyed by a single label value.
func NewCounterVec ¶
func NewCounterVec() *CounterVec
func (*CounterVec) Snapshot ¶
func (cv *CounterVec) Snapshot() []LabelValue
func (*CounterVec) WithLabel ¶
func (cv *CounterVec) WithLabel(val string) *Counter
type Gauge ¶
type Gauge struct {
// contains filtered or unexported fields
}
Gauge is a numeric value that can go up and down.
type Histogram ¶
type Histogram struct {
// contains filtered or unexported fields
}
Histogram tracks the distribution of observed values in predefined buckets.
func NewHistogram ¶
type HistogramVec ¶
type HistogramVec struct {
// contains filtered or unexported fields
}
HistogramVec is a set of Histograms keyed by a single label value.
func NewHistogramVec ¶
func NewHistogramVec(buckets []float64) *HistogramVec
func (*HistogramVec) Snapshot ¶
func (hv *HistogramVec) Snapshot() []LabelHistogram
func (*HistogramVec) WithLabel ¶
func (hv *HistogramVec) WithLabel(val string) *Histogram
type LabelHistogram ¶
type LabelValue ¶
type NetworkMetricSnapshot ¶
type NetworkMetricSnapshot struct {
Name string
Members int
Owners int
Admins int
Enterprise bool
PolicySet bool
}
NetworkMetricSnapshot holds per-network metrics computed on each scrape.
type Store ¶
type Store struct {
// Request metrics (labeled by message type)
RequestsTotal *CounterVec // pilot_requests_total{type="..."}
RequestDuration *HistogramVec // pilot_request_duration_seconds{type="..."}
ErrorsTotal *CounterVec // pilot_errors_total{type="..."}
// Gauge metrics (updated on each scrape)
NodesOnline Gauge // pilot_nodes_online
NodesTotal Gauge // pilot_nodes_total
TrustLinks Gauge // pilot_trust_links
TaskExecutors Gauge // pilot_task_executors
UptimeSeconds Gauge // pilot_uptime_seconds
// Lifecycle counters
Registrations Counter // pilot_registrations_total
Deregistrations Counter // pilot_deregistrations_total
TrustReports Counter // pilot_trust_reports_total
TrustRevocations Counter // pilot_trust_revocations_total
HandshakeRequests Counter // pilot_handshake_requests_total
// Network gauges (updated on each scrape)
NetworksTotal Gauge // pilot_networks_total
NetworksEnterprise Gauge // pilot_networks_enterprise
InvitesPending Gauge // pilot_invites_pending
// Enterprise counters
AuditEventsTotal Counter // pilot_audit_events_total
InvitesSent Counter // pilot_invites_sent_total
InvitesAccepted Counter // pilot_invites_accepted_total
InvitesRejected Counter // pilot_invites_rejected_total
RbacOps *CounterVec // pilot_rbac_operations_total{op="..."}
PolicyChanges Counter // pilot_policy_changes_total
KeyRotations Counter // pilot_key_rotations_total
// Provisioning counters
ProvisionsTotal Counter // pilot_provisions_total
AuditExportsTotal Counter // pilot_audit_exports_total
AuditExportErrors Counter // pilot_audit_export_errors_total
IdpVerifications Counter // pilot_idp_verifications_total
RbacPreAssignments Counter // pilot_rbac_pre_assignments_total
// Reliability counters (Phase 3 wiring)
WalFull Counter // pilot_wal_full_total
WalErrors Counter // pilot_wal_errors_total
SaveFailures Counter // pilot_save_failures_total
// Save lifecycle — one tick per flushSave call
SaveTotal Counter // pilot_save_total
SaveLastUnixSeconds Gauge // pilot_save_last_unix_seconds — Unix s of last successful save
SaveDuration *Histogram // pilot_save_duration_seconds — wall time per flushSave
// Per-action audit breakdown (label = action)
AuditActions *CounterVec // pilot_audit_action_total{action="..."}
// Signature verify outcomes (label = result: ok|fail)
SignatureVerify *CounterVec // pilot_signature_verify_total{result="..."}
// Event-bus publish total (single hot path, no labels)
EventBusPublish Counter // pilot_event_bus_publish_total
// Event-bus publish broken down by "source.type" so operators can see
// what's actually flowing through the bus (membership.changed vs
// trust.created vs audit.entry vs ...). Label is the concatenated
// dot-namespaced event name from the publisher.
EventBusPublishByType *CounterVec // pilot_event_bus_publish_by_type_total{event="..."}
// Webhook delivery counters — per-outcome counter vec + last delivery
// timestamp. Lets operators see whether the configured webhook is
// actually firing and whether deliveries are succeeding.
WebhookDeliveries *CounterVec // pilot_webhook_deliveries_total{result="ok|error"} (declared, populated from WebhookStatsFn at scrape time)
WebhookLastUnix Gauge // pilot_webhook_last_delivery_unix_seconds
// WebhookStatsFn surfaces the webhook store's atomic counters at
// scrape time. ok=false (no URL configured) → the webhook block is
// omitted entirely, same as BeaconStatsFn. Source in webhook.Stats().
WebhookStatsFn func() (delivered, failed, dropped uint64, lastUnix int64, ok bool)
// Rate-limit denials by kind (label = kind: ip|punch|relay|discover)
RateLimitDenied *CounterVec // pilot_ratelimit_denied_total{kind="..."}
// BeaconStatsFn surfaces the beacon's atomic relay counters when wired.
// nil when no beacon is attached; the scrape omits the metrics in that
// case so a registry without a beacon doesn't read as 0 traffic.
BeaconStatsFn func() (forwarded, dropped, notFound uint64, ok bool)
// RegistryInternalsFn surfaces server-internal state that's not part of
// the request path (pubkey index size, WAL bytes, replication epoch +
// role). The closure is invoked at scrape time so the values are always
// fresh. nil → the metrics are omitted from the scrape output.
RegistryInternalsFn func() (pubkeys uint64, walSize uint64, term uint64, isStandby bool, ok bool)
NetworkMetrics []NetworkMetricSnapshot
// Enterprise status gauges
IdpConfigured Gauge // pilot_idp_configured (0 or 1)
WebhookConfigured Gauge // pilot_webhook_configured (0 or 1)
AuditExportActive Gauge // pilot_audit_export_active (0 or 1)
DirectorySynced Gauge // pilot_directory_synced_networks
// Runtime / saturation observability
RuntimeGoroutines Gauge // pilot_runtime_goroutines
RuntimeConnectionsTCP Gauge // pilot_registry_tcp_connections
HandshakeInboxSize Gauge // pilot_handshake_inbox_size
HandshakeRespSize Gauge // pilot_handshake_responses_size
// list_nodes cache observability
ListNodesCacheHits Gauge // pilot_list_nodes_cache_hits
ListNodesCacheWaits Gauge // pilot_list_nodes_cache_waits
ListNodesCacheRebuilds Gauge // pilot_list_nodes_cache_rebuilds
// PanicCountFn returns the total recovered-panic count since process start.
// Injected at construction so WriteTo can surface it without importing server.
PanicCountFn func() uint64
// contains filtered or unexported fields
}
Store aggregates all Prometheus metrics for the registry server. It is intentionally zero-external-dependency.
func (*Store) GetNetworkMetrics ¶
func (st *Store) GetNetworkMetrics() []NetworkMetricSnapshot
GetNetworkMetrics returns a copy of the per-network snapshot slice (thread-safe).
func (*Store) SetNetworkMetrics ¶
func (st *Store) SetNetworkMetrics(snaps []NetworkMetricSnapshot)
SetNetworkMetrics replaces the per-network snapshot slice (thread-safe).