Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateStorageUsage(ctx context.Context, sqlExecutor func() ie.InternalExecutor) (err error)
- func CheckNewAccountSize(ctx context.Context, logger *log.MOLogger, ...)
- func CreateCronTask(ctx context.Context, executorID task.TaskCode, ...) error
- 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 GetExportToProm() bool
- func GetForceInit() bool
- func GetGatherInterval() time.Duration
- func GetMetricStorageUsageExecutor(sqlExecutor func() ie.InternalExecutor) func(ctx context.Context, task task.Task) error
- func GetRawHistBufLimit() int32
- func GetStatsGatherInterval() time.Duration
- func GetStorageUsageCheckNewInterval() time.Duration
- func GetUpdateStorageUsageInterval() 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
- func SetStorageUsageCheckNewInterval(interval time.Duration)
- func SetUpdateStorageUsageInterval(interval time.Duration)
- func TaskMetadata(jobName string, id task.TaskCode, args ...string) task.TaskMetadata
- type Collector
- type 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 ( LoggerName = "MetricTask" LoggerNameMetricStorage = "MetricStorage" StorageUsageCronTask = "StorageUsage" StorageUsageTaskCronExpr = ExprEvery05Min ExprEvery05Min = "0 */1 * * * *" ParamSeparator = " " )
const ( ShowAllAccountSQL = "SHOW ACCOUNTS;" ShowAccountSQL = "SHOW ACCOUNTS like %q;" ColumnAccountName = "account_name" // result column in `show accounts`, or column in table mo_catalog.mo_account ColumnSize = "size" // result column in `show accounts`, or column in table mo_catalog.mo_account ColumnCreatedTime = "created_time" // column in table mo_catalog.mo_account ColumnStatus = "status" // column in table mo_catalog.mo_account )
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, ) 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, ) )
var ( LblNodeConst = "node" LblRoleConst = "role" LblValueConst = "value" LblTimeConst = "collecttime" )
var AllSubSystem = map[string]*SubSystem{}
var InitCollectors = []Collector{ StatementCounterFactory, StatementErrorsFactory, TransactionCounterFactory, TransactionErrorsFactory, ConnFactory, StorageUsageFactory, processCollector, hardwareStatsCollector, }
var QuitableWait = func(ctx context.Context) (*time.Ticker, error) { next := time.NewTicker(GetUpdateStorageUsageInterval()) return next, nil }
Functions ¶
func CalculateStorageUsage ¶ added in v0.7.0
func CalculateStorageUsage(ctx context.Context, sqlExecutor func() ie.InternalExecutor) (err error)
func CheckNewAccountSize ¶ added in v0.8.0
func CreateCronTask ¶ added in v0.7.0
func CreateCronTask(ctx context.Context, executorID task.TaskCode, taskService taskservice.TaskService) error
CreateCronTask should init once in/with schema-init.
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 GetExportToProm ¶ added in v0.8.0
func GetExportToProm() bool
func GetForceInit ¶ added in v0.8.0
func GetForceInit() bool
func GetGatherInterval ¶ added in v0.8.0
func GetMetricStorageUsageExecutor ¶ added in v0.7.0
func GetMetricStorageUsageExecutor(sqlExecutor func() ie.InternalExecutor) func(ctx context.Context, task task.Task) error
GetMetricStorageUsageExecutor collect metric server_storage_usage
func GetRawHistBufLimit ¶ added in v0.8.0
func GetRawHistBufLimit() int32
func GetStatsGatherInterval ¶ added in v0.8.0
func GetStorageUsageCheckNewInterval ¶ added in v0.8.0
func GetUpdateStorageUsageInterval ¶ added in v0.7.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
func SetStorageUsageCheckNewInterval ¶ added in v0.8.0
func SetUpdateStorageUsageInterval ¶ added in v0.7.0
func TaskMetadata ¶ added in v0.7.0
TaskMetadata handle args like: "{db_tbl_name} [date, default: today]"
Types ¶
type Counter ¶
func StatementCounter ¶
StatementCounter accept t as tree.QueryType
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" )