monitoring

package
v0.0.0-...-eaf0976 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapCoreWithLogMetrics

func WrapCoreWithLogMetrics(monitor *LogMetricsMonitor, core zapcore.Core) zapcore.Core

WrapCoreWithLogMetrics returns a zapcore.Core that hooks into every write to increment the log-message counter for warn and error entries.

Types

type Config

type Config struct {
	// Monitoring configuration
	Monitoring RegistryConfig `json:"monitoring"`
}

type LogMetricsMonitor

type LogMetricsMonitor struct {
	// contains filtered or unexported fields
}

LogMetricsMonitor owns the log-message counter and implements the prometheus.Collector interface so it can be registered with the metrics registry like every other Monitor in cortex.

func NewLogMetricsMonitor

func NewLogMetricsMonitor() LogMetricsMonitor

NewLogMetricsMonitor creates a new monitor for log-level metrics.

func (*LogMetricsMonitor) Collect

func (m *LogMetricsMonitor) Collect(ch chan<- prometheus.Metric)

func (*LogMetricsMonitor) Describe

func (m *LogMetricsMonitor) Describe(ch chan<- *prometheus.Desc)

type MetricsSlogHandler

type MetricsSlogHandler struct {
	// contains filtered or unexported fields
}

MetricsSlogHandler wraps an slog.Handler and increments the log-message counter for every warn or error log record.

func NewMetricsSlogHandler

func NewMetricsSlogHandler(monitor *LogMetricsMonitor, next slog.Handler) *MetricsSlogHandler

NewMetricsSlogHandler returns a new handler that counts warn/error logs and delegates all calls to next.

func (*MetricsSlogHandler) Enabled

func (h *MetricsSlogHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*MetricsSlogHandler) Handle

func (h *MetricsSlogHandler) Handle(ctx context.Context, r slog.Record) error

func (*MetricsSlogHandler) WithAttrs

func (h *MetricsSlogHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*MetricsSlogHandler) WithGroup

func (h *MetricsSlogHandler) WithGroup(name string) slog.Handler

type RegistererGatherer

type RegistererGatherer interface {
	prometheus.Registerer
	prometheus.Gatherer
}

type Registry

type Registry struct {
	// Inherited prometheus registry.
	RegistererGatherer
	// contains filtered or unexported fields
}

Custom prometheus registry that adds functionality to the default registry.

func NewRegistry

func NewRegistry(config Config) *Registry

Create a new registry with the given configuration. This registry will include the default go collector and process collector.

func WrapRegistry

func WrapRegistry(registry RegistererGatherer, config Config) *Registry

func (*Registry) Gather

func (r *Registry) Gather() ([]*dto.MetricFamily, error)

Custom gather method that adds custom labels to all metrics.

type RegistryConfig

type RegistryConfig struct {
	// The labels to add to all metrics.
	Labels map[string]string `json:"labels"`

	// The port to expose the metrics on.
	Port int `json:"port"`
}

Configuration for our custom registry.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL