metrics

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LblRes    = "res"
	LblStatus = "status"
)
View Source
const (
	LblBackend       = "backend"
	LblFrom          = "from"
	LblTo            = "to"
	LblMigrateResult = "migrate_res"
)

Label constants.

View Source
const (
	LabelServer  = "server"
	LabelBalance = "balance"
	LabelSession = "session"
	LabelMonitor = "monitor"
	LabelBackend = "backend"
	LabelTraffic = "traffic"
)

metrics labels.

View Source
const (
	LblType = "type"

	EventStart = "start"
	EventClose = "close"
)
View Source
const (
	LblCmdType = "cmd_type"
)

LblCmdType is the label constant.

View Source
const (
	ModuleProxy = "tiproxy"
)

Variables

View Source
var (
	BackendStatusGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelBackend,
			Name:      "b_status",
			Help:      "Gauge of backend status.",
		}, []string{LblBackend, LblStatus})

	GetBackendHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelBackend,
			Name:      "get_backend_duration_seconds",
			Help:      "Bucketed histogram of time (s) for getting an available backend.",
			Buckets:   prometheus.ExponentialBuckets(0.000001, 2, 26),
		})

	GetBackendCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelBackend,
			Name:      "get_backend",
			Help:      "Counter of getting backend.",
		}, []string{LblRes})

	PingBackendGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelBackend,
			Name:      "ping_duration_seconds",
			Help:      "Time (s) of pinging the SQL port of each backend.",
		}, []string{LblBackend})

	HealthCheckCycleGauge = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelBackend,
			Name:      "health_check_seconds",
			Help:      "Time (s) of each health check cycle.",
		})
)
View Source
var (
	BackendConnGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelBalance,
			Name:      "b_conn",
			Help:      "Number of backend connections.",
		}, []string{LblBackend})

	MigrateCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelBalance,
			Name:      "migrate_total",
			Help:      "Number and result of session migration.",
		}, []string{LblFrom, LblTo, LblMigrateResult})

	MigrateDurationHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelBalance,
			Name:      "migrate_duration_seconds",
			Help:      "Bucketed histogram of migrating time (s) of sessions.",
			Buckets:   prometheus.ExponentialBuckets(0.0001, 2, 26),
		}, []string{LblFrom, LblTo, LblMigrateResult})
)
View Source
var (
	ConnGauge = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelServer,
			Name:      "connections",
			Help:      "Number of connections.",
		})

	CreateConnCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelServer,
			Name:      "create_connection_total",
			Help:      "Number of create connections.",
		})

	DisConnCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelServer,
			Name:      "disconnection_total",
			Help:      "Number of disconnections.",
		}, []string{LblType})

	MaxProcsGauge = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelServer,
			Name:      "maxprocs",
			Help:      "The value of GOMAXPROCS.",
		})

	ServerEventCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelServer,
			Name:      "event",
			Help:      "Counter of TiProxy event.",
		}, []string{LblType})

	ServerErrCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelServer,
			Name:      "err",
			Help:      "Counter of server error.",
		}, []string{LblType})

	TimeJumpBackCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelMonitor,
			Name:      "time_jump_back_total",
			Help:      "Counter of system time jumps backward.",
		})

	KeepAliveCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelMonitor,
			Name:      "keep_alive_total",
			Help:      "Counter of proxy keep alive.",
		})
)
View Source
var (
	QueryTotalCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelSession,
			Name:      "query_total",
			Help:      "Counter of queries.",
		}, []string{LblBackend, LblCmdType})

	QueryDurationHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelSession,
			Name:      "query_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of handled queries.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblBackend, LblCmdType})

	HandshakeDurationHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelSession,
			Name:      "handshake_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of handshakes.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblBackend})
)
View Source
var (
	InboundBytesCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelTraffic,
			Name:      "inbound_bytes",
			Help:      "Counter of bytes from backends.",
		}, []string{LblBackend})

	InboundPacketsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelTraffic,
			Name:      "inbound_packets",
			Help:      "Counter of packets from backends.",
		}, []string{LblBackend})

	OutboundBytesCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelTraffic,
			Name:      "outbound_bytes",
			Help:      "Counter of bytes to backends.",
		}, []string{LblBackend})

	OutboundPacketsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: ModuleProxy,
			Subsystem: LabelTraffic,
			Name:      "outbound_packets",
			Help:      "Counter of packets to backends.",
		}, []string{LblBackend})
)

Functions

func ReadCounter

func ReadCounter(counter prometheus.Counter) (int, error)

ReadCounter reads the value from the counter. It is only used for testing.

func ReadGauge

func ReadGauge(gauge prometheus.Gauge) (float64, error)

ReadGauge reads the value from the gauge. It is only used for testing.

Types

type MetricsManager

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

MetricsManager manages metrics.

func NewMetricsManager

func NewMetricsManager() *MetricsManager

NewMetricsManager creates a MetricsManager.

func (*MetricsManager) Close

func (mm *MetricsManager) Close()

Close stops all goroutines.

func (*MetricsManager) Init

func (mm *MetricsManager) Init(ctx context.Context, logger *zap.Logger)

Init registers metrics and pushes metrics to prometheus.

Jump to

Keyboard shortcuts

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