Documentation
¶
Index ¶
- Constants
- Variables
- func CurrentNetworkStatInputByte() float64
- func CurrentNetworkStatOutputByte() float64
- func GetNetstat() (tcp map[string]int, err error)
- func NewDesc(metricName string, docString string, labels []string) *prometheus.Desc
- func ReadNumberFromFile(name string) (n float64, err error)
- func RunPrometheusExporter(mon *Monitor, c *ExporterConf) error
- type BigKeyConfS
- type BigKeyDataS
- type BigKeyExporter
- type BigKeyExporterConf
- type BigKeyMonitorDataS
- type BigKeyPair
- type BigKeyStatistics
- func (b *BigKeyStatistics) Filter()
- func (b *BigKeyStatistics) GetBigKeyCount() int
- func (b *BigKeyStatistics) GetBigKeyPairArray() []BigKeyPair
- func (b *BigKeyStatistics) GetBigKeyValueSizeSum() int
- func (b *BigKeyStatistics) Init(data []BigKeyDataS, threshold int)
- func (b *BigKeyStatistics) Len() int
- func (b *BigKeyStatistics) Less(i, j int) bool
- func (b *BigKeyStatistics) Swap(i, j int)
- type ExporterConf
- type Fields
- type FieldsFunc
- type HotKeyConfS
- type HotKeyCountDataS
- type HotKeyDataS
- type HotKeyExporter
- type HotKeyExporterConf
- type HotKeyMonitorDataS
- type HotKeyPair
- type HotKeyStatistics
- func (h *HotKeyStatistics) Filter()
- func (h *HotKeyStatistics) GetHotKeyPairArray() []HotKeyPair
- func (h *HotKeyStatistics) GetHotKeyTotal() int
- func (h *HotKeyStatistics) Init(data *HotKeyMonitorDataS, threshold int)
- func (h *HotKeyStatistics) Len() int
- func (h *HotKeyStatistics) Less(i, j int) bool
- func (h *HotKeyStatistics) Swap(i, j int)
- type KeyMonitor
- type Monitor
- func (m *Monitor) AddBigKeyCacheItem(cache *cache.Cache, key, value []byte, expireMilliSeconds int) bool
- func (m *Monitor) AddHotKeyCacheItem(cache *cache.Cache, key string, value []byte, expireMilliSeconds int) bool
- func (m *Monitor) BeginMonitorHotKey()
- func (m *Monitor) GetBigKeyData() []BigKeyDataS
- func (m *Monitor) GetSlowQueryData() (data []*SlowQueryDataS, count int)
- func (m *Monitor) IsShouldPutHotKey() bool
- func (m *Monitor) IsSlowQuery(args []interface{}, startTime time.Time, endTime time.Time)
- func (m *Monitor) PutBigKey(key string, valueSize int) bool
- func (m *Monitor) PutHotKey(key string, value []byte)
- type NetStatCallback
- type NetworkExporter
- type NetworkStat
- type RunTimeExporterConf
- type RuntimeExporter
- type SlowQueryConfS
- type SlowQueryDataS
- type SlowQueryExporter
- type SlowQueryExporterConf
- type SlowQueryMonitorDataS
- type SlowQueryPair
- type SlowQueryStatistics
- func (s *SlowQueryStatistics) Filter()
- func (s *SlowQueryStatistics) GetQueryPairArray() []SlowQueryPair
- func (s *SlowQueryStatistics) Init(data []*SlowQueryDataS, threshold int)
- func (s *SlowQueryStatistics) Len() int
- func (s *SlowQueryStatistics) Less(i, j int) bool
- func (s *SlowQueryStatistics) Swap(i, j int)
- type TimePair
Constants ¶
View Source
const ( WORK_STATUS_ING = 1 WORK_STATUS_STOP = 2 )
hotkey任务状态值 * 通过原子操作进行状态的更新。
View Source
const INIT_INDEX = -1
View Source
const Namespace = "redisproxy"
Variables ¶
View Source
var BasicLabels = []string{"host"}
View Source
var BasicLabelsMap = map[string]string{}
Functions ¶
func CurrentNetworkStatInputByte ¶
func CurrentNetworkStatInputByte() float64
func CurrentNetworkStatOutputByte ¶
func CurrentNetworkStatOutputByte() float64
func GetNetstat ¶
func ReadNumberFromFile ¶
func RunPrometheusExporter ¶
func RunPrometheusExporter(mon *Monitor, c *ExporterConf) error
Types ¶
type BigKeyConfS ¶
type BigKeyDataS ¶
type BigKeyDataS struct {
// contains filtered or unexported fields
}
type BigKeyExporter ¶
type BigKeyExporter struct {
// contains filtered or unexported fields
}
func NewBigKeyExporter ¶
func NewBigKeyExporter(mon *Monitor, c *ExporterConf) *BigKeyExporter
func (*BigKeyExporter) Collect ¶
func (b *BigKeyExporter) Collect(ch chan<- prometheus.Metric)
func (*BigKeyExporter) Describe ¶
func (b *BigKeyExporter) Describe(ch chan<- *prometheus.Desc)
type BigKeyExporterConf ¶
type BigKeyMonitorDataS ¶
type BigKeyPair ¶
type BigKeyPair struct {
// contains filtered or unexported fields
}
type BigKeyStatistics ¶
type BigKeyStatistics struct {
// contains filtered or unexported fields
}
func (*BigKeyStatistics) Filter ¶
func (b *BigKeyStatistics) Filter()
func (*BigKeyStatistics) GetBigKeyCount ¶
func (b *BigKeyStatistics) GetBigKeyCount() int
func (*BigKeyStatistics) GetBigKeyPairArray ¶
func (b *BigKeyStatistics) GetBigKeyPairArray() []BigKeyPair
func (*BigKeyStatistics) GetBigKeyValueSizeSum ¶
func (b *BigKeyStatistics) GetBigKeyValueSizeSum() int
func (*BigKeyStatistics) Init ¶
func (b *BigKeyStatistics) Init(data []BigKeyDataS, threshold int)
func (*BigKeyStatistics) Len ¶
func (b *BigKeyStatistics) Len() int
func (*BigKeyStatistics) Less ¶
func (b *BigKeyStatistics) Less(i, j int) bool
func (*BigKeyStatistics) Swap ¶
func (b *BigKeyStatistics) Swap(i, j int)
type ExporterConf ¶
type ExporterConf struct {
Enable bool `mapstructure:"enable"`
Host string `mapstructure:"host"`
Address string `mapstructure:"address"`
HotKeyExporterConf HotKeyExporterConf `mapstructure:"hotkey_exporter"`
BigKeyExporterConf BigKeyExporterConf `mapstructure:"bigkey_exporter"`
SlowQueryConf SlowQueryExporterConf `mapstructure:"slowquery_exporter"`
RunTimeExporterConf RunTimeExporterConf `mapstructure:"runtime_exporter"`
}
func (*ExporterConf) SetDefaultHostname ¶
func (e *ExporterConf) SetDefaultHostname()
type Fields ¶
type Fields struct {
NumCPU int64 `json:"cpu.count"`
NumGoroutine int64 `json:"cpu.goroutines"`
Alloc int64 `json:"mem.alloc"`
TotalAlloc int64 `json:"mem.total"`
Sys int64 `json:"mem.sys"`
Lookups int64 `json:"mem.lookups"`
Mallocs int64 `json:"mem.malloc"`
Frees int64 `json:"mem.frees"`
HeapAlloc int64 `json:"mem.heap.alloc"`
HeapSys int64 `json:"mem.heap.sys"`
HeapIdle int64 `json:"mem.heap.idle"`
HeapInuse int64 `json:"mem.heap.inuse"`
HeapReleased int64 `json:"mem.heap.released"`
HeapObjects int64 `json:"mem.heap.objects"`
StackInuse int64 `json:"mem.stack.inuse"`
StackSys int64 `json:"mem.stack.sys"`
MSpanInuse int64 `json:"mem.stack.mspan_inuse"`
MSpanSys int64 `json:"mem.stack.mspan_sys"`
MCacheInuse int64 `json:"mem.stack.mcache_inuse"`
MCacheSys int64 `json:"mem.stack.mcache_sys"`
OtherSys int64 `json:"mem.othersys"`
GCSys int64 `json:"mem.gc.sys"`
NextGC int64 `json:"mem.gc.next"`
LastGC int64 `json:"mem.gc.last"`
PauseTotalNs int64 `json:"mem.gc.pause_total"`
PauseNs int64 `json:"mem.gc.pause"`
NumGC int64 `json:"mem.gc.count"`
GCCPUFraction float64 `json:"mem.gc.cpu_fraction"`
}
type FieldsFunc ¶
type FieldsFunc func(Fields)
type HotKeyConfS ¶
type HotKeyCountDataS ¶
type HotKeyDataS ¶
type HotKeyExporter ¶
type HotKeyExporter struct {
// contains filtered or unexported fields
}
func NewHotKeyExporter ¶
func NewHotKeyExporter(mon *Monitor, c *ExporterConf) *HotKeyExporter
func (*HotKeyExporter) Collect ¶
func (n *HotKeyExporter) Collect(ch chan<- prometheus.Metric)
func (*HotKeyExporter) Describe ¶
func (n *HotKeyExporter) Describe(ch chan<- *prometheus.Desc)
type HotKeyExporterConf ¶
type HotKeyMonitorDataS ¶
type HotKeyMonitorDataS struct {
HotKeyData HotKeyCountDataS
TimeRange *TimePair
sync.RWMutex
}
func (*HotKeyMonitorDataS) ReSetData ¶
func (hkmd *HotKeyMonitorDataS) ReSetData()
type HotKeyPair ¶
type HotKeyPair struct {
// contains filtered or unexported fields
}
type HotKeyStatistics ¶
type HotKeyStatistics struct {
// contains filtered or unexported fields
}
func (*HotKeyStatistics) Filter ¶
func (h *HotKeyStatistics) Filter()
func (*HotKeyStatistics) GetHotKeyPairArray ¶
func (h *HotKeyStatistics) GetHotKeyPairArray() []HotKeyPair
func (*HotKeyStatistics) GetHotKeyTotal ¶
func (h *HotKeyStatistics) GetHotKeyTotal() int
func (*HotKeyStatistics) Init ¶
func (h *HotKeyStatistics) Init(data *HotKeyMonitorDataS, threshold int)
func (*HotKeyStatistics) Len ¶
func (h *HotKeyStatistics) Len() int
func (*HotKeyStatistics) Less ¶
func (h *HotKeyStatistics) Less(i, j int) bool
func (*HotKeyStatistics) Swap ¶
func (h *HotKeyStatistics) Swap(i, j int)
type KeyMonitor ¶
type Monitor ¶
type Monitor struct {
Cache *cache.Cache
KeyMonitor *KeyMonitor
HotKeyConf *HotKeyConfS
HotKeyMonitorData *HotKeyMonitorDataS
BigKeyConf *BigKeyConfS
BigKeyMonitorData *BigKeyMonitorDataS
SlowQueryConf *SlowQueryConfS
SlowQueryMonitorData *SlowQueryMonitorDataS
ConnectionGauge prometheus.Gauge
sync.RWMutex
}
func GetNewMonitor ¶
func GetNewMonitor(hotKeyConf *HotKeyConfS, bigKeyConf *BigKeyConfS, slowQueryConf *SlowQueryConfS) (m *Monitor, err error)
func (*Monitor) AddBigKeyCacheItem ¶
func (*Monitor) AddHotKeyCacheItem ¶
func (m *Monitor) AddHotKeyCacheItem(cache *cache.Cache, key string, value []byte, expireMilliSeconds int) bool
*AddHotKeyCacheItem(cache缓存对象,cache的key,cache的数据体,超时时间-毫秒) *这个函数主要支撑hotkey数据的缓存写入工作,当检测出hotkey时,判断是否开启了cache功能,如果开启了则进行cache的写入工作。
func (*Monitor) BeginMonitorHotKey ¶
func (m *Monitor) BeginMonitorHotKey()
*BeginMonitorHotKey() *这个函数主要启动HotKey的监控工作,监控工作主要包括以下几部分: * 1.原子切换hotkey任务执行状态,WORK_STATUS_STOP状态代表任务监控停止,WORK_STATUS_ING状态代表正在进行hotkey监控 * 2.hotkey任务监控等待:等待的目的主要是为了让requesthandle可以在这段时间内统计hotkey lRU数据 * 3.对于监控获得的数据进行hotkey LRU数据进行汇总工作,并把hotkey存储到hotkeys汇总数据内存中。 * 4.把hotkeys中的数据并发安全的存储到HotKeyMonitorData数据中,这个数据可以供外部调用并发安全的访问。
func (*Monitor) GetBigKeyData ¶
func (m *Monitor) GetBigKeyData() []BigKeyDataS
func (*Monitor) GetSlowQueryData ¶
func (m *Monitor) GetSlowQueryData() (data []*SlowQueryDataS, count int)
func (*Monitor) IsShouldPutHotKey ¶
*IsShouldPutHotKey() *这个函数主要用来判断当前时机是不是应该可以进行hotkey的统计操作 *通过这个函数的前置判断,避免不必要的函数参数传递而造成的性能损耗
func (*Monitor) IsSlowQuery ¶
type NetStatCallback ¶
type NetStatCallback func(stat *NetworkStat, err error)
type NetworkExporter ¶
type NetworkExporter struct {
// contains filtered or unexported fields
}
func NewNetExporter ¶
func NewNetExporter(c *ExporterConf) *NetworkExporter
func (*NetworkExporter) Collect ¶
func (s *NetworkExporter) Collect(ch chan<- prometheus.Metric)
func (*NetworkExporter) Describe ¶
func (s *NetworkExporter) Describe(ch chan<- *prometheus.Desc)
type NetworkStat ¶
type RunTimeExporterConf ¶
type RuntimeExporter ¶
type RuntimeExporter struct {
// contains filtered or unexported fields
}
func NewRuntimeExport ¶
func NewRuntimeExport(c *ExporterConf) *RuntimeExporter
func (*RuntimeExporter) Collect ¶
func (r *RuntimeExporter) Collect(ch chan<- prometheus.Metric)
func (*RuntimeExporter) Describe ¶
func (r *RuntimeExporter) Describe(ch chan<- *prometheus.Desc)
type SlowQueryConfS ¶
type SlowQueryDataS ¶
type SlowQueryExporter ¶
type SlowQueryExporter struct {
// contains filtered or unexported fields
}
func NewSlowQueryExporter ¶
func NewSlowQueryExporter(mon *Monitor, c *ExporterConf) *SlowQueryExporter
func (*SlowQueryExporter) Collect ¶
func (s *SlowQueryExporter) Collect(ch chan<- prometheus.Metric)
func (*SlowQueryExporter) Describe ¶
func (s *SlowQueryExporter) Describe(ch chan<- *prometheus.Desc)
type SlowQueryExporterConf ¶
type SlowQueryExporterConf struct {
RecordLimit int `mapstructure:"record_limit"`
}
type SlowQueryMonitorDataS ¶
type SlowQueryMonitorDataS struct {
SlowQueryDataList []*SlowQueryDataS
Index int32
sync.RWMutex
}
type SlowQueryPair ¶
type SlowQueryPair struct {
// contains filtered or unexported fields
}
type SlowQueryStatistics ¶
type SlowQueryStatistics struct {
// contains filtered or unexported fields
}
func (*SlowQueryStatistics) Filter ¶
func (s *SlowQueryStatistics) Filter()
func (*SlowQueryStatistics) GetQueryPairArray ¶
func (s *SlowQueryStatistics) GetQueryPairArray() []SlowQueryPair
func (*SlowQueryStatistics) Init ¶
func (s *SlowQueryStatistics) Init(data []*SlowQueryDataS, threshold int)
func (*SlowQueryStatistics) Len ¶
func (s *SlowQueryStatistics) Len() int
func (*SlowQueryStatistics) Less ¶
func (s *SlowQueryStatistics) Less(i, j int) bool
func (*SlowQueryStatistics) Swap ¶
func (s *SlowQueryStatistics) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.