Documentation
¶
Overview ¶
Package metrics provides Prometheus metrics instrumentation for confd. Metrics are optional and only initialized when --metrics-addr is specified.
Index ¶
- Variables
- func Enabled() bool
- func HealthHandler(_ backends.StoreClient) http.HandlerFunc
- func Initialize()
- func ReadyDetailedHandler(client backends.StoreClient) http.HandlerFunc
- func ReadyHandler(client backends.StoreClient) http.HandlerFunc
- func WrapStoreClient(client backends.StoreClient, backendType string) backends.StoreClient
- type InstrumentedClient
- func (c *InstrumentedClient) Close() error
- func (c *InstrumentedClient) GetValues(ctx context.Context, keys []string) (map[string]string, error)
- func (c *InstrumentedClient) HealthCheck(ctx context.Context) error
- func (c *InstrumentedClient) HealthCheckDetailed(ctx context.Context) (*types.HealthResult, error)
- func (c *InstrumentedClient) WatchPrefix(ctx context.Context, prefix string, keys []string, waitIndex uint64, ...) (uint64, error)
Constants ¶
This section is empty.
Variables ¶
var ( BackendRequestDuration *prometheus.HistogramVec BackendRequestTotal *prometheus.CounterVec BackendErrorsTotal *prometheus.CounterVec BackendHealthy *prometheus.GaugeVec )
Backend metrics
var ( TemplateProcessDuration *prometheus.HistogramVec TemplateProcessTotal *prometheus.CounterVec TemplateCacheHits prometheus.Counter TemplateCacheMisses prometheus.Counter TemplateStatCacheHits prometheus.Counter TemplatesLoaded prometheus.Gauge WatchedKeys prometheus.Gauge )
Template metrics
var ( BatchProcessTotal prometheus.Counter BatchProcessFailed prometheus.Counter BatchProcessTemplatesSucceeded prometheus.Counter BatchProcessTemplatesFailed prometheus.Counter )
Batch processing metrics
var ( CommandDuration *prometheus.HistogramVec CommandTotal *prometheus.CounterVec CommandExitCodes *prometheus.CounterVec )
Command metrics
var ( FileSyncTotal *prometheus.CounterVec FileChangedTotal prometheus.Counter )
File sync metrics
var Registry *prometheus.Registry
Registry holds all confd metrics. It is nil when metrics are disabled.
Functions ¶
func HealthHandler ¶
func HealthHandler(_ backends.StoreClient) http.HandlerFunc
HealthHandler returns HTTP 200 if the process is alive. This is a liveness probe - it always returns OK if the process is running.
func Initialize ¶
func Initialize()
Initialize creates and registers all metrics with a new registry. Call this only when metrics are enabled (--metrics-addr is set).
func ReadyDetailedHandler ¶
func ReadyDetailedHandler(client backends.StoreClient) http.HandlerFunc
ReadyDetailedHandler returns detailed health check information as JSON. Returns HTTP 200 with detailed health info if backend is healthy, 503 otherwise.
func ReadyHandler ¶
func ReadyHandler(client backends.StoreClient) http.HandlerFunc
ReadyHandler returns HTTP 200 if the backend is reachable, 503 otherwise. This is a readiness probe - it checks backend connectivity.
func WrapStoreClient ¶
func WrapStoreClient(client backends.StoreClient, backendType string) backends.StoreClient
WrapStoreClient wraps a StoreClient with metrics instrumentation. If metrics are not enabled (Registry is nil), returns the original client.
Types ¶
type InstrumentedClient ¶
type InstrumentedClient struct {
// contains filtered or unexported fields
}
InstrumentedClient wraps a StoreClient with metrics instrumentation.
func (*InstrumentedClient) Close ¶
func (c *InstrumentedClient) Close() error
Close closes the wrapped backend client.
func (*InstrumentedClient) GetValues ¶
func (c *InstrumentedClient) GetValues(ctx context.Context, keys []string) (map[string]string, error)
GetValues retrieves values from the backend and records metrics.
func (*InstrumentedClient) HealthCheck ¶
func (c *InstrumentedClient) HealthCheck(ctx context.Context) error
HealthCheck verifies backend health and records metrics.
func (*InstrumentedClient) HealthCheckDetailed ¶
func (c *InstrumentedClient) HealthCheckDetailed(ctx context.Context) (*types.HealthResult, error)
HealthCheckDetailed provides detailed health information if the backend supports it.