CovenantSQL: Index | Files

package metric

import ""

Package metric implements CPU, Mem, Disk etc metrics gathering and storing

Metric Types:


Package Files

collector.go covenantmetric.go cpu_common.go cpu_linux.go diskstats_linux.go doc.go filesystem_common.go filesystem_linux.go helper.go loadavg.go loadavg_linux.go meminfo.go meminfo_linux.go meminfo_numa_linux.go metric.go metricweb.go nodemetricmap.go ntp.go rpc.go


const MetricServiceName = "Metric"

MetricServiceName is the RPC name.


var ProcPath = "/proc"

ProcPath is the proc system path, expose for test.

func CovenantSQLIdle Uses

func CovenantSQLIdle(cc *CovenantSQLCollector) float64

CovenantSQLIdle gets the idle of DB.

func InitMetricWeb Uses

func InitMetricWeb(metricWeb string) (err error)

InitMetricWeb initializes the /debug/metrics web.

func NewCovenantSQLCollector Uses

func NewCovenantSQLCollector() prometheus.Collector

NewCovenantSQLCollector returns a new CovenantSQLCollector.

func StartMetricCollector Uses

func StartMetricCollector() (registry *prometheus.Registry)

StartMetricCollector starts collector registered in NewNodeCollector().

type CollectClient Uses

type CollectClient struct {
    Registry *prometheus.Registry

CollectClient is the Metric Collect Client.

func NewCollectClient Uses

func NewCollectClient() *CollectClient

NewCollectClient returns a new CollectClient.

func (*CollectClient) GatherMetricBytes Uses

func (cc *CollectClient) GatherMetricBytes() (mfb [][]byte, err error)

GatherMetricBytes gathers the registered metric info and encode it to [][]byte.

func (*CollectClient) UploadMetrics Uses

func (cc *CollectClient) UploadMetrics(BPNodeID proto.NodeID) (err error)

UploadMetrics calls RPC UploadMetrics to upload its metric info.

type CollectServer Uses

type CollectServer struct {
    NodeMetric NodeMetricMap // map[proto.NodeID]SimpleMetricMap

CollectServer is the Metric receiver side.

func NewCollectServer Uses

func NewCollectServer() *CollectServer

NewCollectServer returns a new CollectServer.

func (*CollectServer) UploadMetrics Uses

func (cs *CollectServer) UploadMetrics(req *proto.UploadMetricsReq, resp *proto.UploadMetricsResp) (err error)

UploadMetrics RPC uploads metric info.

type Collector Uses

type Collector interface {
    // Get new metrics and expose them via prometheus Registry.
    Update(ch chan<- prometheus.Metric) error

Collector is the interface a collector has to implement.

func NewCPUCollector Uses

func NewCPUCollector() (Collector, error)

NewCPUCollector returns a new Collector exposing kernel/system statistics.

func NewDiskstatsCollector Uses

func NewDiskstatsCollector() (Collector, error)

NewDiskstatsCollector returns a new Collector exposing disk device stats.

func NewFilesystemCollector Uses

func NewFilesystemCollector() (Collector, error)

NewFilesystemCollector returns a new Collector exposing filesystems stats.

func NewLoadavgCollector Uses

func NewLoadavgCollector() (Collector, error)

NewLoadavgCollector returns a new Collector exposing load average stats.

func NewMeminfoCollector Uses

func NewMeminfoCollector() (Collector, error)

NewMeminfoCollector returns a new Collector exposing memory stats.

type CovenantSQLCollector Uses

type CovenantSQLCollector struct {
    // contains filtered or unexported fields

CovenantSQLCollector collects CovenantSQL metrics.

func (*CovenantSQLCollector) Collect Uses

func (cc *CovenantSQLCollector) Collect(ch chan<- prometheus.Metric)

Collect returns the current state of all metrics of the collector.

func (*CovenantSQLCollector) CovenantSQLPrepared Uses

func (cc *CovenantSQLCollector) CovenantSQLPrepared() bool

CovenantSQLPrepared returns true when the metric is ready to be collected.

func (*CovenantSQLCollector) Describe Uses

func (cc *CovenantSQLCollector) Describe(ch chan<- *prometheus.Desc)

Describe returns all descriptions of the collector.

type FilterFunc Uses

type FilterFunc func(key proto.NodeID, value SimpleMetricMap) bool

FilterFunc is a function that knows how to filter a specific node that match the metric limits. if node picked return true else false.

type NodeCollector Uses

type NodeCollector struct {
    Collectors map[string]Collector

NodeCollector implements the prometheus.Collector interface.

func NewNodeCollector Uses

func NewNodeCollector() (*NodeCollector, error)

NewNodeCollector creates a new NodeCollector.

func (NodeCollector) Collect Uses

func (n NodeCollector) Collect(ch chan<- prometheus.Metric)

Collect implements the prometheus.Collector interface.

func (NodeCollector) Describe Uses

func (n NodeCollector) Describe(ch chan<- *prometheus.Desc)

Describe implements the prometheus.Collector interface.

type NodeCrucialMetricMap Uses

type NodeCrucialMetricMap map[proto.NodeID]map[string]float64

NodeCrucialMetricMap is map[NodeID][MetricName]Value.

type NodeMetricMap Uses

type NodeMetricMap struct {
    sync.Map // map[proto.NodeID]SimpleMetricMap

NodeMetricMap is sync.Map version of map[proto.NodeID]SimpleMetricMap.

func (*NodeMetricMap) FilterNode Uses

func (nmm *NodeMetricMap) FilterNode(filterFunc FilterFunc) (ret []proto.NodeID)

FilterNode return node id slice make filterFunc return true.

func (*NodeMetricMap) GetCrucialMetrics Uses

func (nmm *NodeMetricMap) GetCrucialMetrics() (ret NodeCrucialMetricMap)

GetCrucialMetrics gets NodeCrucialMetricMap from NodeMetricMap.

func (*NodeMetricMap) GetMetrics Uses

func (nmm *NodeMetricMap) GetMetrics(nodes []proto.NodeID) (metrics map[proto.NodeID]SimpleMetricMap)

GetMetrics returns nodes metrics.

type SimpleMetricMap Uses

type SimpleMetricMap map[string]*dto.MetricFamily

SimpleMetricMap is map from metric name to MetricFamily.

func (*SimpleMetricMap) FilterCrucialMetrics Uses

func (mfm *SimpleMetricMap) FilterCrucialMetrics() (ret map[string]float64)

FilterCrucialMetrics filters crucial metrics and also add cpu_count.

Package metric imports 31 packages (graph). Updated 2019-08-13. Refresh now. Tools for package owners.