Documentation
¶
Overview ¶
Package metrics defines and registers all Prometheus metrics for sqi-server.
Callers obtain a *Metrics via New and pass it to the components that record observations. Using a private prometheus.Registry rather than the global default registry prevents cross-contamination between test instances and avoids collision with Go runtime metrics.
Metrics.SchedulerTasksTotal, Metrics.SchedulerAssignmentDuration, Metrics.NATSPublishedTotal, Metrics.NATSConsumedTotal and Metrics.DBQueryDuration are registered, but no server code records into them, so they serve no samples. The other families are written by the scheduler and the other components named on their fields.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
// HTTPRequestsTotal counts completed HTTP requests, labeled by HTTP
// method, request path, and response status code.
//
// The "path" label is the chi route pattern, such as /api/v1/jobs/{id};
// see middleware.RequestMetrics for the values it takes when no route
// matched. The "method" label is OTHER for a non-standard method.
HTTPRequestsTotal *prometheus.CounterVec
// HTTPRequestDuration records request latency in seconds, labeled by HTTP
// method and request path.
HTTPRequestDuration *prometheus.HistogramVec
// SchedulerQueueDepth is the current number of ready tasks waiting for
// assignment in each named queue. Set by the scheduler.
SchedulerQueueDepth *prometheus.GaugeVec
// SchedulerTasksTotal counts task completions, labeled by queue name and
// terminal status (succeeded, failed, canceled). Nothing records it.
SchedulerTasksTotal *prometheus.CounterVec
// SchedulerTasksReconciled counts attempts reclaimed because their worker
// stopped reporting them (scheduler.reconcile_grace).
SchedulerTasksReconciled prometheus.Counter
// SchedulerCancelsResent counts the cancels the heartbeat sweep sends to a
// worker whose heartbeat still lists an attempt the store has closed
// (cause "closed") or has no record of (cause "unknown").
SchedulerCancelsResent *prometheus.CounterVec
// SchedulerAssignmentDuration records the wall-clock time spent in a
// single call to tryAssign, labeled by result:
// - "assigned" — a worker was found and the task was dispatched.
// - "deferred" — no eligible worker or policy blocked; task stays ready.
// - "error" — an unexpected error aborted the attempt.
//
// Nothing records it.
SchedulerAssignmentDuration *prometheus.HistogramVec
// SchedulerIdleWorkers is the current count of online workers that have no
// task in 'assigned' or 'running' state, partitioned by farm ID.
// Updated by the scheduler after each worker-registry or sweep event.
SchedulerIdleWorkers *prometheus.GaugeVec
// SchedulerIngestLagSeconds is how far the newest ingest marker each
// scheduler consumer has processed trails now, by consumer (worker,
// task); before the first marker, the time since the scheduler started.
SchedulerIngestLagSeconds *prometheus.GaugeVec
// SchedulerIngestPending is the number of messages each scheduler
// consumer failed to apply and will receive again, by consumer (worker,
// task).
SchedulerIngestPending *prometheus.GaugeVec
// SchedulerWorkerReregisterRequests counts the requests the scheduler
// sends a worker it holds offline whose heartbeats still arrive, asking it
// to register again, by outcome: accepted, refused, or error (no reply,
// or one that would not decode).
SchedulerWorkerReregisterRequests *prometheus.CounterVec
// WorkersTotal is the current number of registered workers, partitioned by
// status: online, offline, or disabled. Set by the scheduler.
WorkersTotal *prometheus.GaugeVec
// NATSPublishedTotal counts messages published to the NATS broker,
// labeled by subject. Nothing records it.
NATSPublishedTotal *prometheus.CounterVec
// NATSConsumedTotal counts messages consumed from the NATS broker,
// labeled by subject. Nothing records it.
NATSConsumedTotal *prometheus.CounterVec
// DBQueryDuration records SQLite query execution time in seconds, labeled
// by operation name (e.g. "job.insert", "task.list"). Nothing records it.
DBQueryDuration *prometheus.HistogramVec
// UsageActiveClaims is the current number of active (unreleased)
// usage-pool claims for each named pool. Updated by the scheduler on every
// dispatch tick.
UsageActiveClaims *prometheus.GaugeVec
// TaskRetriesTotal counts tasks re-queued by automatic retry, partitioned
// by queue name. Incremented by the scheduler's failure fork.
TaskRetriesTotal *prometheus.CounterVec
// JobsAutoParkedTotal counts jobs auto-parked at their failure limit,
// partitioned by queue name. Incremented by the scheduler's failure fork.
JobsAutoParkedTotal *prometheus.CounterVec
// CapacityDemandCores is the cores of ready work assigned to each group:
// work one of its machines could run that no idle worker and no
// higher-priority group took.
CapacityDemandCores *prometheus.GaugeVec
// CapacityDesiredMachines is the total number of machines each group
// should have, counting the machines it already has.
CapacityDesiredMachines *prometheus.GaugeVec
// CapacityMembers counts each group's members by liveness (state online
// or offline).
CapacityMembers *prometheus.GaugeVec
// CapacityMachines counts each acting group's members by power state
// (awake, waking, retiring, asleep, wake_failed).
CapacityMachines *prometheus.GaugeVec
// CapacityActionsTotal counts provider actions by group, action (wake,
// grow, retire, list) and result (ok, failed, refused, unsupported,
// timeout, expired).
CapacityActionsTotal *prometheus.CounterVec
// CapacityBootTimeoutsTotal counts woken machines that did not register
// within their group's boot timeout.
CapacityBootTimeoutsTotal *prometheus.CounterVec
// CapacityGroupDegraded is 1 while an acting group is degraded and 0
// otherwise.
CapacityGroupDegraded *prometheus.GaugeVec
// HALeader is 1 while this server leads its high-availability group and 0
// otherwise, including on a server outside a group. Every server of a
// group is scraped; the leader is the one reporting 1.
HALeader prometheus.Gauge
// HAEpoch is the leadership epoch: the one this server leads at, or on a
// standby the one it last saw the leader hold.
HAEpoch prometheus.Gauge
// HAPromotions counts this process's promotions to leader: at most one,
// since a demoted leader exits.
HAPromotions prometheus.Counter
// HADemotions counts losses of leadership, partitioned by reason
// (renew_refused, deadline, fenced, guard_lost, broker_lost,
// promotion_failed). The process exits after one, so the series is
// mostly read from its last scrape and the exit code.
HADemotions *prometheus.CounterVec
// contains filtered or unexported fields
}
Metrics holds every Prometheus metric family for sqi-server and the isolated registry they are registered against. Obtain one with New.
func New ¶
func New() *Metrics
New creates a *Metrics and registers all metric families — plus the standard Go runtime and process collectors — against a fresh prometheus.Registry.
func (*Metrics) Handler ¶
Handler returns an http.Handler that serves the Prometheus text exposition format (and OpenMetrics when the client requests it) for all metrics registered in this *Metrics' private registry.
func (*Metrics) RegisterHA ¶ added in v0.4.0
func (m *Metrics) RegisterHA()
RegisterHA exposes the sqi_server_ha_* families. A server in a high-availability group calls it once at start; further calls do nothing. Without it the families can be written to but are not served, so a server outside a group serves no sqi_server_ha_* series and a sqi_server_ha_leader == 1 selector never matches it.