kk_monitor

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CollectHub *collectorHub

Functions

func InitCollectorHub

func InitCollectorHub(engine *gin.Engine)

Types

type Collector

type Collector interface {
	Update()
	// AutoTrigger auto trigger the update by Interval() when true
	// default is true
	// if you use middleware, AutoTrigger is usually false
	AutoTrigger() bool
	Metrics() []*Metric
	// Interval the interval of the Update() to collect metrics
	Interval() time.Duration
	Middleware(c *gin.Context)
	// contains filtered or unexported methods
}

Collector can collect many metrics by one Update()

type DefaultCollector

type DefaultCollector struct{}

func (*DefaultCollector) AutoTrigger

func (x *DefaultCollector) AutoTrigger() bool

func (*DefaultCollector) Interval

func (x *DefaultCollector) Interval() time.Duration

func (*DefaultCollector) Metrics

func (x *DefaultCollector) Metrics() []*Metric

func (*DefaultCollector) Middleware

func (x *DefaultCollector) Middleware(c *gin.Context)

func (*DefaultCollector) Update

func (x *DefaultCollector) Update()

type Metric

type Metric struct {
	Metric *prometheus.GaugeVec

	// every metric may have an alert rule
	//todo push alert to prometheus config
	AlertRule *v1.AlertingRule
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(name string, labels []string) *Metric

func (*Metric) GenAlertRuleYaml

func (m *Metric) GenAlertRuleYaml() string

func (*Metric) Register

func (m *Metric) Register(registry *prometheus.Registry)

func (*Metric) Unregister

func (m *Metric) Unregister(registry *prometheus.Registry)

Jump to

Keyboard shortcuts

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