metric

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Type_Cluster = iota
	Type_Mac
	Type_Process
	Type_DB
	Type_Table
)
View Source
const (
	TYPE_SQL           = "sql"
	TYPE_ELASTICSEARCH = "elasticsearch"

	NAMESPACE_CLUSTER  = "cluster"
	NAMESPACE_MAC      = "mac"
	NAMESPACE_PROCESS  = "process"
	NAMESPACE_DB       = "db"
	NAMESPACE_TABLE    = "table"
	NAMESPACE_TASK     = "task"
	NAMESPACE_SCHEDULE = "schedule"
	NAMESPACE_HOTSPOT  = "hotspot"
	NAMESPACE_NODE     = "node"
	NAMESPACE_RANGE    = "range"

	METRIC_TASK_STATS       = "task_stats"
	METRIC_CLUSTER_META     = "cluster_meta"
	METRIC_CLUSTER_NET      = "cluster_net"
	METRIC_CLUSTER_SLOWLOG  = "cluster_slowlog"
	METRIC_MAC_META         = "mac_meta"
	METRIC_MAC_NET          = "mac_net"
	METRIC_MAC_MEM          = "mac_mem"
	METRIC_MAC_DISK         = "mac_disk"
	METRIC_PROCESS_META     = "process_meta"
	METRIC_PROCESS_DISK     = "process_disk"
	METRIC_PROCESS_NET      = "process_net"
	METRIC_PROCESS_DS       = "process_ds"
	METRIC_DB_META          = "db_meta"
	METRIC_TABLE_META       = "table_meta"
	METRIC_SCHEDULE_COUNTER = "schedule_counter"
	METRIC_HOTSPOT          = "hotspot_stats"
	METRIC_NODE_STATS       = "node_stats"
	METRIC_RANGE_STATS      = "range_stats"
)

Variables

View Source
var (
	ClusterMetaSQL = `` /* 210-byte string literal not displayed */

	ClusterNetSQL = `` /* 229-byte string literal not displayed */

	MacMetaSQL = `` /* 176-byte string literal not displayed */

	MacNetSQL = `` /* 509-byte string literal not displayed */

	MacMemSQL = `` /* 271-byte string literal not displayed */

	MacDiskSQL = `` /* 279-byte string literal not displayed */

	ProcessMetaSQL = `` /* 197-byte string literal not displayed */

	ProcessDiskSQL = `` /* 285-byte string literal not displayed */

	ProcessNetSQL = `` /* 342-byte string literal not displayed */

	ProcessDsSQL = `` /* 240-byte string literal not displayed */

	DbMetaSQL    = `insert into db_meta (cluster_id, db_name, table_num, range_size, update_time) values (%d,"%s",%d,%d,%d)`
	TableMetaSQL = `insert into table_meta (cluster_id, db_name, table_name, range_count, range_size, update_time) values (%d,"%s","%s",%d,%d,%d)`
	TaskMetaSQL  = `insert into task_meta (cluster_id, finish_time, used_time, state, describe, update_time) values (%d,%d,%d,"%s","%s",%d)`

	RangeStatsSQL = `` /* 173-byte string literal not displayed */
)

Functions

func GetIndexRule added in v0.6.3

func GetIndexRule(metric string) string

*

standard:
range_stats: range_stats-yyyy-MM

Types

type Cluster

type Cluster struct {
	ClusterId uint64

	Item *ClusterItem

	DbCache      *DbItemCache
	MacCache     *MacItemCache
	ProcessCache *ProcessItemCache

	LastReportTime time.Time
}

func NewCluster

func NewCluster(clusterId uint64) *Cluster

func (*Cluster) GetDbItem

func (c *Cluster) GetDbItem(name string) *DbItem

func (*Cluster) GetMacItem

func (c *Cluster) GetMacItem(ip string) *MacItem

func (*Cluster) GetProcessItem

func (c *Cluster) GetProcessItem(addr string) *ProcessItem

func (*Cluster) SetDbItem

func (c *Cluster) SetDbItem(db *DbItem)

func (*Cluster) SetMacItem

func (c *Cluster) SetMacItem(item *MacItem)

func (*Cluster) SetProcessItem

func (c *Cluster) SetProcessItem(item *ProcessItem)

type ClusterCache

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

func NewClusterCache

func NewClusterCache() *ClusterCache

func (*ClusterCache) Get

func (c *ClusterCache) Get(clusterId uint64) *Cluster

func (*ClusterCache) GetAll

func (c *ClusterCache) GetAll() []*Cluster

func (*ClusterCache) Set

func (c *ClusterCache) Set(item *Cluster)

type ClusterItem

type ClusterItem struct {
	ClusterId          uint64  `json:"cluster_id"`
	CapacityTotal      uint64  `json:"capacity_total"`
	SizeUsed           uint64  `json:"size_used"`
	RangeNum           uint64  `json:"range_num"`
	DbNum              uint64  `json:"db_num"`
	TableNum           uint64  `json:"table_num"`
	TaskNum            uint64  `json:"task_num"`
	NodeUpCount        uint64  `json:"node_up_count,omitempty"`
	NodeDownCount      uint64  `json:"node_down_count,omitempty"`
	NodeOfflineCount   uint64  `json:"node_offline_count,omitempty"`
	NodeTombstoneCount uint64  `json:"node_tombstone_count,omitempty"`
	LeaderBalanceRatio float64 `json:"leader_balance_ratio,omitempty"`
	RegionBalanceRatio float64 `json:"region_balance_ratio,omitempty"`
	GsNum              uint64  `json:"gs_num"`

	Tps uint64 `json:"tps"`
	// 客户端请求最小延时
	Min float64 `json:"min"`
	// 客户端请求最大延时
	Max float64 `json:"max"`
	// 平均延时
	Avg float64 `json:"avg"`
	// TP ...
	TP50        float64 `json:"tp50"`
	TP90        float64 `json:"tp90"`
	TP99        float64 `json:"tp99"`
	TP999       float64 `json:"tp999"`
	TotalNumber uint64  `json:"total_number"`
	ErrNumber   uint64  `json:"err_number"`

	// 默认保留1000条 ??
	SlowLog []string `json:"slow_log"`

	// GS 出入口网络统计
	NetIoInBytePerSec       uint64 `json:"net_io_in_byte_per_sec"`
	NetIoOutBytePerSec      uint64 `json:"net_io_out_byte_per_sec"`
	NetIoInPackagePerSec    uint64 `json:"net_io_in_package_per_sec"`
	NetIoOutPackagePerSec   uint64 `json:"net_io_out_package_per_sec"`
	NetTcpConnections       uint32 `json:"net_tcp_connections"`
	NetTcpActiveOpensPerSec uint32 `json:"net_tcp_activeopens_per_sec"`

	// 更新时间
	UpdateTime int64 `json:"-"`
}

type Context

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

type DbItem

type DbItem struct {
	DbName     string `json:"name"`
	TableNum   uint32 `json:"table_num"`
	Size       uint64 `json:"size"`
	UpdateTime int64  `json:"-"`

	TableCache *TableItemCache `json:"-"`
}

func NewDbItem

func NewDbItem(name string) *DbItem

func (*DbItem) GetTableItem

func (i *DbItem) GetTableItem(name string) *TableItem

func (*DbItem) SetTableTtem

func (i *DbItem) SetTableTtem(item *TableItem)

type DbItemCache

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

func NewDbCache

func NewDbCache() *DbItemCache

func (*DbItemCache) Get

func (c *DbItemCache) Get(name string) *DbItem

func (*DbItemCache) GetAll

func (c *DbItemCache) GetAll() []*DbItem

func (*DbItemCache) Set

func (c *DbItemCache) Set(item *DbItem)

type EsStore

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

func (*EsStore) Close

func (s *EsStore) Close()

func (*EsStore) Open

func (s *EsStore) Open() error

func (*EsStore) Put

func (s *EsStore) Put(message *Message) error

type MacItem

type MacItem struct {
	Type string
	// Ip 地址
	Ip string

	UpdateTime int64

	Item *statspb.MacStats
}

type MacItemCache

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

func NewMacItemCache

func NewMacItemCache() *MacItemCache

func (*MacItemCache) Get

func (c *MacItemCache) Get(addr string) *MacItem

func (*MacItemCache) GetAll

func (c *MacItemCache) GetAll() []*MacItem

func (*MacItemCache) Set

func (c *MacItemCache) Set(item *MacItem)

type Message

type Message struct {
	// 集群
	ClusterId uint64
	// 系统
	Namespace string
	// 子系统
	Subsystem string
	// MsgId
	MsgId string
	// item
	Items interface{}
}

type Metric

type Metric struct {
	AlarmCli  *alarm.Client
	Threshold ThresholdConfig
	// contains filtered or unexported fields
}

func NewMetric

func NewMetric(svr *server.Server, store Store, threshold ThresholdConfig) *Metric

func NewRawMetric

func NewRawMetric(ip string, port uint16, store Store) *Metric

func (*Metric) Open

func (m *Metric) Open() error

func (*Metric) Start

func (m *Metric) Start()

func (*Metric) Stop

func (m *Metric) Stop()

type NodeThreshold

type NodeThreshold struct {
	CapacityUsedRate uint64 `toml:"capacity-used-rate" json:"capacity-used-rate"` // capacity/used_city in node stats
	WriteBps         uint64 `toml:"write-bps" json:"write-bps"`
	WriteOps         uint64 `toml:"write-ops" json:"write-ops"`
	ReadBps          uint64 `toml:"read-bps" json:"read-bps"`
	ReadOps          uint64 `toml:"read-ops" json:"read-ops"`
}

type ProcessItem

type ProcessItem struct {
	// 类型: MS, DS, GS
	Type string
	// 地址
	Addr string

	UpdateTime int64

	Item *statspb.ProcessStats

	SlowLog *statspb.SlowLogStats
}

type ProcessItemCache

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

func NewProcessItemCache

func NewProcessItemCache() *ProcessItemCache

func (*ProcessItemCache) Get

func (c *ProcessItemCache) Get(addr string) *ProcessItem

func (*ProcessItemCache) GetAll

func (c *ProcessItemCache) GetAll() []*ProcessItem

func (*ProcessItemCache) Set

func (c *ProcessItemCache) Set(item *ProcessItem)

type RangeThreshold

type RangeThreshold struct {
	WriteBps uint64 `toml:"write-bps" json:"write-bps"`
	WriteOps uint64 `toml:"write-ops" json:"write-ops"`
	ReadBps  uint64 `toml:"read-bps" json:"read-bps"`
	ReadOps  uint64 `toml:"read-ops" json:"read-ops"`
}

type SlowLogItem

type SlowLogItem struct {
	// 类型: MS, DS, GS
	Type string
	// 地址
	Addr string

	UpdateTime int64

	Item *statspb.SlowLogStats
}

type SqlStore

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

func (*SqlStore) Close

func (s *SqlStore) Close()

func (*SqlStore) Open

func (s *SqlStore) Open() error

func (*SqlStore) Put

func (s *SqlStore) Put(message *Message) error

type Store

type Store interface {
	Open() error
	Put(message *Message) error
	Close()
}

func NewEsStore

func NewEsStore(nodes []string, worker_num int) Store

func NewSqlStore

func NewSqlStore(dns string, worker_num int) Store

type TableItem

type TableItem struct {
	DbName     string `json:"db_name"`
	TableName  string `json:"table_name"`
	RangeNum   uint64 `json:"range_num"`
	Size       uint64 `json:"size"`
	UpdateTime int64  `json:"-"`
}

type TableItemCache

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

func NewTableItemCache

func NewTableItemCache() *TableItemCache

func (*TableItemCache) Get

func (c *TableItemCache) Get(name string) *TableItem

func (*TableItemCache) GetAll

func (c *TableItemCache) GetAll() []*TableItem

func (*TableItemCache) Set

func (c *TableItemCache) Set(item *TableItem)

type TaskItem

type TaskItem struct {
	UpdateTime int64
	*statspb.TaskInfo
}

type ThresholdConfig

type ThresholdConfig struct {
	Node  NodeThreshold  `toml:"node-threshold" json:"node-threshold"`
	Range RangeThreshold `toml:"range-threshold" json:"range-threshold"`
}

Jump to

Keyboard shortcuts

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