Documentation ¶
Index ¶
- Constants
- Variables
- func EnableExportToProm() bool
- func EnvOrDefaultBool(key string, defaultValue int32) int32
- func EnvOrDefaultInt[T int32 | int64](key string, defaultValue T) T
- func ExponentialBuckets(start, factor float64, count int) []float64
- func GetForceInit() bool
- func GetGatherInterval() time.Duration
- func GetRawHistBufLimit() int32
- func GetStatsGatherInterval() time.Duration
- func IsFullBatchRawHist(mf *pb.MetricFamily) bool
- func NewCounter(opts prom.CounterOpts) *ratecounter
- func NewCounterVec(opts CounterOpts, lvs []string, doAvg bool) *rateCounterVec
- func NewGauge(opts prom.GaugeOpts) *gauge
- func NewGaugeVec(opts prom.GaugeOpts, lvs []string) *gaugeVec
- func NewRawHist(opts prom.HistogramOpts) *rawHist
- func RegisterSubSystem(s *SubSystem)
- func SetExportToProm(new bool) bool
- func SetGatherInterval(new time.Duration) time.Duration
- func SetMetricExporter(e MetricExporter)
- func SetRawHistBufLimit(new int32) int32
- type Collector
- type Counter
- func MOLogMessageCounter(level string) Counter
- func StatementCUCounter(account string, sqlSourceType string) Counter
- func StatementCounter(tenant string, t string) Counter
- func StatementDuration(tenant string, t string) Counter
- func StatementErrorsCounter(account string, t string) Counter
- func TransactionCounter(tenant string) Counter
- func TransactionErrorsCounter(account string, t SQLType) Counter
- type CounterOpts
- type ExporterHolder
- type Gauge
- type GaugeOpts
- type HistogramOpts
- type MetricExporter
- type Observer
- type RawHistVec
- func (v *RawHistVec) CancelToProm()
- func (v *RawHistVec) Collect(ch chan<- prom.Metric)
- func (v *RawHistVec) CollectorToProm() prom.Collector
- func (v *RawHistVec) Describe(ch chan<- *prom.Desc)
- func (v *RawHistVec) GetMetricWithLabelValues(lvs ...string) (Observer, error)
- func (v *RawHistVec) WithLabelValues(lvs ...string) prom.Observer
- type SQLType
- type SubSystem
Constants ¶
const ( // SubSystemSql is the subsystem which base on query action. SubSystemSql = "sql" // SubSystemServer is the subsystem which base on server status, trigger by client query. SubSystemServer = "server" // SubSystemProcess is the subsystem which base on process status. SubSystemProcess = "process" // SubSystemSys is the subsystem which base on OS status. SubSystemSys = "sys" // SubSystemMO is the subsystem which show mo internal status SubSystemMO = "mo" )
const MetricDBConst = "system_metrics"
Variables ¶
var ( ConnFactory = NewGaugeVec( GaugeOpts{ Subsystem: "server", Name: "connections", Help: "Number of process connections", }, []string{constTenantKey}, ) StorageUsageFactory = NewGaugeVec( GaugeOpts{ Subsystem: "server", Name: "storage_usage", Help: "Storage usage of each account", }, []string{constTenantKey}, ) )
var ( StatementCounterFactory = NewCounterVec( CounterOpts{ Subsystem: "sql", Name: "statement_total", Help: "Counter of executed sql statement", }, []string{constTenantKey, "type"}, false, ) StatementDurationFactory = NewCounterVec( CounterOpts{ Subsystem: "sql", Name: "statement_duration_total", Help: "Statement duration of each query type for each account", }, []string{constTenantKey, "type"}, false, ) TransactionCounterFactory = NewCounterVec( CounterOpts{ Subsystem: "sql", Name: "transaction_total", Help: "Counter of transaction", }, []string{constTenantKey}, false, ) TransactionErrorsFactory = NewCounterVec( CounterOpts{ Subsystem: "sql", Name: "transaction_errors", Help: "Counter of errors on execute commit/rollback statement", }, []string{constTenantKey, "type"}, false, ) StatementErrorsFactory = NewCounterVec( CounterOpts{ Subsystem: "sql", Name: "statement_errors", Help: "Counter of executed sql statement failed.", }, []string{constTenantKey, "type"}, false, ) StatementCUCounterFactory = NewCounterVec( CounterOpts{ Subsystem: "sql", Name: "statement_cu", Help: "Counter of executed sql statement cu", }, []string{constTenantKey, "sql_source_type"}, false, ) )
var ( LblNodeConst = "node" LblRoleConst = "role" LblValueConst = "value" LblTimeConst = "collecttime" )
var AllSubSystem = map[string]*SubSystem{}
var InitCollectors = []Collector{ StatementCounterFactory, StatementErrorsFactory, StatementCUCounterFactory, TransactionCounterFactory, TransactionErrorsFactory, StatementDurationFactory, ConnFactory, StorageUsageFactory, processCollector, hardwareStatsCollector, }
InitCollectors contains all the collectors that belong to SubSystemSql, SubSystemServer, SubSystemProcess and SubSystemStatement.
var InternalCollectors = []Collector{ MOLogMessageFactory, }
InternalCollectors contains all the collectors that belong to SubSystemMO
var ( MOLogMessageFactory = NewCounterVec( CounterOpts{ Subsystem: SubSystemMO, Name: "log_message_count", Help: "Count of log message", }, []string{constTenantKey, "type"}, false, ) )
Functions ¶
func EnableExportToProm ¶ added in v1.0.0
func EnableExportToProm() bool
func EnvOrDefaultBool ¶ added in v0.8.0
func EnvOrDefaultInt ¶ added in v0.8.0
func ExponentialBuckets ¶
ExponentialBuckets produces list like `[start, start * factor, start * factor^2, ..., start * factor^(count-1)]`
func GetForceInit ¶ added in v0.8.0
func GetForceInit() bool
func GetGatherInterval ¶ added in v0.8.0
func GetRawHistBufLimit ¶ added in v0.8.0
func GetRawHistBufLimit() int32
func GetStatsGatherInterval ¶ added in v0.8.0
func IsFullBatchRawHist ¶ added in v0.8.0
func IsFullBatchRawHist(mf *pb.MetricFamily) bool
func NewCounter ¶
func NewCounter(opts prom.CounterOpts) *ratecounter
func NewCounterVec ¶
func NewCounterVec(opts CounterOpts, lvs []string, doAvg bool) *rateCounterVec
func NewGaugeVec ¶
func NewRawHist ¶
func NewRawHist(opts prom.HistogramOpts) *rawHist
func RegisterSubSystem ¶ added in v0.8.0
func RegisterSubSystem(s *SubSystem)
func SetExportToProm ¶ added in v0.8.0
func SetMetricExporter ¶ added in v0.8.0
func SetMetricExporter(e MetricExporter)
func SetRawHistBufLimit ¶ added in v0.8.0
Types ¶
type Counter ¶
func MOLogMessageCounter ¶ added in v1.0.0
func StatementCUCounter ¶ added in v1.1.2
StatementCUCounter accept @account, @sqlSourceType @account is the account name of the user who executes the sql statement. @sqlSourceType is the type of sql source, such as InternalSql, CloudNoUserSql, ExternalSql, CloudUserSql etc.
func StatementCounter ¶
StatementCounter accept t as tree.QueryType
func StatementDuration ¶ added in v1.1.2
func StatementErrorsCounter ¶ added in v0.6.0
StatementErrorsCounter accept t as tree.QueryType
func TransactionCounter ¶ added in v0.6.0
func TransactionErrorsCounter ¶ added in v0.6.0
type CounterOpts ¶
type CounterOpts = prom.CounterOpts
type ExporterHolder ¶ added in v0.8.0
func NewExportHolder ¶ added in v0.8.0
func NewExportHolder(e MetricExporter) *ExporterHolder
func (*ExporterHolder) Get ¶ added in v0.8.0
func (h *ExporterHolder) Get() MetricExporter
type HistogramOpts ¶
type HistogramOpts = prom.HistogramOpts
type MetricExporter ¶
type RawHistVec ¶
type RawHistVec struct {
// contains filtered or unexported fields
}
RawHistVec is a Collector that bundles a set of RawHist that all share the same Desc, but have different values for their variable labels. It can be used as a factory for a series of Observers
func NewRawHistVec ¶
func NewRawHistVec(opts prom.HistogramOpts, labelNames []string) *RawHistVec
NewRawHistVec creates a new NewRawHistVec based on the provided HistogramOpts and partitioned by the given label names.
func (*RawHistVec) CancelToProm ¶
func (v *RawHistVec) CancelToProm()
func (*RawHistVec) Collect ¶
func (v *RawHistVec) Collect(ch chan<- prom.Metric)
func (*RawHistVec) CollectorToProm ¶
func (v *RawHistVec) CollectorToProm() prom.Collector
func (*RawHistVec) Describe ¶
func (v *RawHistVec) Describe(ch chan<- *prom.Desc)
func (*RawHistVec) GetMetricWithLabelValues ¶
func (v *RawHistVec) GetMetricWithLabelValues(lvs ...string) (Observer, error)
func (*RawHistVec) WithLabelValues ¶
func (v *RawHistVec) WithLabelValues(lvs ...string) prom.Observer
type SQLType ¶
type SQLType string
var ( SQLTypeSelect SQLType = "select" SQLTypeInsert SQLType = "insert" SQLTypeUpdate SQLType = "update" SQLTypeDelete SQLType = "delete" SQLTypeOther SQLType = "other" SQLTypeBegin SQLType = "begin" SQLTypeCommit SQLType = "commit" SQLTypeRollback SQLType = "rollback" SQLTypeAutoCommit SQLType = "auto_commit" SQLTypeAutoRollback SQLType = "auto_rollback" )