Documentation
¶
Overview ¶
Package metrics exposes the Prometheus metrics of a node (FA-OBS-02, ADR 0025 section 7). Every node has its own registry; no collector is global. The metrics carry no tenant or monitor labels.
Index ¶
- func RequireToken(token string, next http.Handler) http.Handler
- type CheckObserver
- type Metrics
- func (m *Metrics) AlertDelivered(kind, outcome string)
- func (m *Metrics) CheckFinished(typ, result string, d time.Duration)
- func (m *Metrics) CheckStarted(string)
- func (m *Metrics) Handler() http.Handler
- func (m *Metrics) JWKSFetchFailed()
- func (m *Metrics) Serve(ctx context.Context, addr, token string, log *slog.Logger) error
- func (m *Metrics) UserInfoCalled()
- func (m *Metrics) UserInfoFailed()
- type Sources
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RequireToken ¶
RequireToken protects next with a static bearer token (FA-OBS-02, ADR 0025). An empty token leaves next unprotected; the separate listener is then the only protection. The comparison takes constant time and does not reveal the token length.
Types ¶
type CheckObserver ¶
type CheckObserver interface {
CheckStarted(typ string)
CheckFinished(typ, result string, d time.Duration)
}
CheckObserver receives check start and finish events from the scheduler.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics holds the push-side instruments and the scrape-time collector. It implements CheckObserver.
func (*Metrics) AlertDelivered ¶
AlertDelivered counts one alert delivery. kind is the event kind and outcome is e.g. "sent", "failed" or "throttled".
func (*Metrics) CheckFinished ¶
CheckFinished implements CheckObserver.
func (*Metrics) CheckStarted ¶
CheckStarted implements CheckObserver.
func (*Metrics) Handler ¶
Handler serves the metrics of the private registry in the Prometheus text format. It does no authentication; Serve adds the token check.
func (*Metrics) JWKSFetchFailed ¶
func (m *Metrics) JWKSFetchFailed()
JWKSFetchFailed counts one failed fetch of the identity provider's keys.
func (*Metrics) Serve ¶
Serve listens on addr and serves only /metrics, protected by token (see RequireToken). It blocks until ctx ends, then shuts down gracefully.
func (*Metrics) UserInfoCalled ¶
func (m *Metrics) UserInfoCalled()
UserInfoCalled counts one userinfo lookup.
func (*Metrics) UserInfoFailed ¶
func (m *Metrics) UserInfoFailed()
UserInfoFailed counts one failed userinfo lookup.
type Sources ¶
type Sources struct {
// RaftState returns the Raft state, e.g. "Leader" or "Follower".
RaftState func() string
// RaftIndexes returns the applied and commit index and the time since the last leader contact.
RaftIndexes func() (applied, commit uint64, lastContact time.Duration)
// ReplicationLag maps peer to its lag; a negative value means it never caught up.
ReplicationLag func() map[string]time.Duration
// ReplicationDropped maps peer to the number of dropped replication messages.
ReplicationDropped func() map[string]uint64
// DBSizes maps the database ("state", "metrics") to its file and WAL size in bytes.
DBSizes func() map[string]struct{ Size, WAL int64 }
// DiskFree returns the free ratio of the data directory's file system.
DiskFree func() (float64, error)
// OutboxPending returns the number of undelivered notifications. It may block up to the scrape timeout.
OutboxPending func(ctx context.Context) (int, error)
// Degraded reports whether the node is in degraded mode (ADR 0024).
Degraded func() bool
// SystemAlertsActive maps the alert kind to the number of active system alerts.
SystemAlertsActive func(ctx context.Context) (map[string]int, error)
// ClockOffsets maps peer to its clock offset (ADR 0020).
ClockOffsets func() map[string]time.Duration
// Version is the build version exported in pulsequorum_build_info.
Version string
}
Sources are the read-only views the collector takes on each scrape. A nil source means its metrics are not exported. Sources that return an error are left out of that scrape.