metrics

package
v7.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LblAction = "action"

	LblAddIndex      = "add_index"
	LblAddIndexMerge = "add_index_merge_tmp"
	LblModifyColumn  = "modify_column"
)

Label constants.

View Source
const (
	LabelSession   = "session"
	LabelDomain    = "domain"
	LabelDDLOwner  = "ddl-owner"
	LabelDDL       = "ddl"
	LabelDDLWorker = "ddl-worker"
	LabelDDLSyncer = "ddl-syncer"
	LabelGCWorker  = "gcworker"
	LabelAnalyze   = "analyze"

	LabelBatchRecvLoop = "batch-recv-loop"
	LabelBatchSendLoop = "batch-send-loop"

	TiDB         = "tidb"
	LabelScope   = "scope"
	ScopeGlobal  = "global"
	ScopeSession = "session"
	Server       = "server"
	TiKVClient   = "tikvclient"
)

metrics labels.

View Source
const (
	LblUnretryable    = "unretryable"
	LblReachMax       = "reach_max"
	LblOK             = "ok"
	LblError          = "error"
	LblCommit         = "commit"
	LblAbort          = "abort"
	LblRollback       = "rollback"
	LblType           = "type"
	LblDb             = "db"
	LblResult         = "result"
	LblSQLType        = "sql_type"
	LblCoprType       = "copr_type"
	LblGeneral        = "general"
	LblInternal       = "internal"
	LblTxnMode        = "txn_mode"
	LblPessimistic    = "pessimistic"
	LblOptimistic     = "optimistic"
	LblStore          = "store"
	LblAddress        = "address"
	LblBatchGet       = "batch_get"
	LblGet            = "get"
	LblLockKeys       = "lock_keys"
	LblInTxn          = "in_txn"
	LblVersion        = "version"
	LblHash           = "hash"
	LblCTEType        = "cte_type"
	LblAccountLock    = "account_lock"
	LblIdle           = "idle"
	LblRunning        = "executing_sql"
	LblLockWaiting    = "waiting_for_lock"
	LblCommitting     = "committing"
	LblRollingBack    = "rolling_back"
	LblHasLock        = "has_lock"
	LblPhase          = "phase"
	LblModule         = "module"
	LblRCReadCheckTS  = "read_check"
	LblRCWriteCheckTS = "write_check"
)

Label constants.

Variables

View Source
var (
	BindUsageCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "bindinfo",
			Name:      "bind_usage_counter",
			Help:      "Counter of query using sql bind",
		}, []string{LabelScope})

	BindTotalGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "bindinfo",
			Name:      "bind_total_gauge",
			Help:      "Total number of sql bind",
		}, []string{LabelScope, LblType})

	BindMemoryUsage = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "bindinfo",
			Name:      "bind_memory_usage",
			Help:      "Memory usage of sql bind",
		}, []string{LabelScope, LblType})
)

bindinfo metrics.

View Source
var (
	JobsGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "waiting_jobs",
			Help:      "Gauge of jobs.",
		}, []string{LblType})

	HandleJobHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "handle_job_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of handle jobs",
			Buckets:   prometheus.ExponentialBuckets(0.01, 2, 24),
		}, []string{LblType, LblResult})

	BatchAddIdxHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "batch_add_idx_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of batch handle data",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		}, []string{LblType})

	SyncerInit            = "init"
	SyncerRestart         = "restart"
	SyncerClear           = "clear"
	SyncerRewatch         = "rewatch"
	DeploySyncerHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "deploy_syncer_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of deploy syncer",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 20),
		}, []string{LblType, LblResult})

	UpdateSelfVersionHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "update_self_ver_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of update self version",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 20),
		}, []string{LblResult})

	OwnerUpdateGlobalVersion   = "update_global_version"
	OwnerCheckAllVersions      = "check_all_versions"
	OwnerHandleSyncerHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "owner_handle_syncer_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of handle syncer",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 20),
		}, []string{LblType, LblResult})

	// Metrics for ddl_worker.go.
	WorkerNotifyDDLJob      = "notify_job"
	WorkerAddDDLJob         = "add_job"
	WorkerRunDDLJob         = "run_job"
	WorkerFinishDDLJob      = "finish_job"
	WorkerWaitSchemaChanged = "wait_schema_changed"
	DDLWorkerHistogram      = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "worker_operation_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of ddl worker operations",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		}, []string{LblType, LblAction, LblResult})

	CreateDDLInstance = "create_ddl_instance"
	CreateDDL         = "create_ddl"
	DDLOwner          = "owner"
	DDLCounter        = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "worker_operation_total",
			Help:      "Counter of creating ddl/worker and isowner.",
		}, []string{LblType})

	BackfillTotalCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "add_index_total",
			Help:      "Speed of add index",
		}, []string{LblType})

	BackfillProgressGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "backfill_percentage_progress",
			Help:      "Percentage progress of backfill",
		}, []string{LblType})

	DDLJobTableDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "tidb",
		Subsystem: "ddl",
		Name:      "job_table_duration_seconds",
		Help:      "Bucketed histogram of processing time (s) of the 3 DDL job tables",
		Buckets:   prometheus.ExponentialBuckets(0.001, 2, 20),
	}, []string{LblType})

	DDLRunningJobCount = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "ddl",
			Name:      "running_job_count",
			Help:      "Running DDL jobs count",
		}, []string{LblType})
)

Metrics for the DDL package.

View Source
var (
	DistSQLQueryHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "distsql",
			Name:      "handle_query_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of handled queries.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblType, LblSQLType, LblCoprType})

	DistSQLScanKeysPartialHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "distsql",
			Name:      "scan_keys_partial_num",
			Help:      "number of scanned keys for each partial result.",
		},
	)
	DistSQLScanKeysHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "distsql",
			Name:      "scan_keys_num",
			Help:      "number of scanned keys for each query.",
		},
	)
	DistSQLPartialCountHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "distsql",
			Name:      "partial_num",
			Help:      "number of partial results for each query.",
		},
	)
	DistSQLCoprCacheCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "distsql",
			Name:      "copr_cache",
			Help:      "coprocessor cache hit, evict and miss number",
		}, []string{LblType})
	DistSQLCoprClosestReadCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "distsql",
			Name:      "copr_closest_read",
			Help:      "counter of total copr read local read hit.",
		}, []string{LblType})
	DistSQLCoprRespBodySize = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "distsql",
			Name:      "copr_resp_size",
			Help:      "copr task response data size in bytes.",
			Buckets:   prometheus.ExponentialBuckets(1024, 2, 20),
		}, []string{LblStore})
)

distsql metrics.

View Source
var (
	// LoadSchemaCounter records the counter of load schema.
	LoadSchemaCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "domain",
			Name:      "load_schema_total",
			Help:      "Counter of load schema",
		}, []string{LblType})

	// LoadSchemaDuration records the duration of load schema.
	LoadSchemaDuration = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "domain",
			Name:      "load_schema_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) in load schema.",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 20),
		})

	// InfoCacheCounters are the counters of get/hit.
	InfoCacheCounters = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "domain",
			Name:      "infocache_counters",
			Help:      "Counters of infoCache: get/hit.",
		}, []string{LblAction, LblType})
	// InfoCacheCounterGet is the total number of getting entry.
	InfoCacheCounterGet = "get"
	// InfoCacheCounterHit is the cache hit numbers for get.
	InfoCacheCounterHit = "hit"

	// LoadPrivilegeCounter records the counter of load privilege.
	LoadPrivilegeCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "domain",
			Name:      "load_privilege_total",
			Help:      "Counter of load privilege",
		}, []string{LblType})

	// LoadSysVarCacheCounter records the counter of loading sysvars
	LoadSysVarCacheCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "domain",
			Name:      "load_sysvarcache_total",
			Help:      "Counter of load sysvar cache",
		}, []string{LblType})

	SchemaValidatorStop       = "stop"
	SchemaValidatorRestart    = "restart"
	SchemaValidatorReset      = "reset"
	SchemaValidatorCacheEmpty = "cache_empty"
	SchemaValidatorCacheMiss  = "cache_miss"
	// HandleSchemaValidate records the counter of handling schema validate.
	HandleSchemaValidate = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "domain",
			Name:      "handle_schema_validate",
			Help:      "Counter of handle schema validate",
		}, []string{LblType})
)

Metrics for the domain package.

View Source
var (
	// ExecutorCounter records the number of expensive executors.
	ExecutorCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "expensive_total",
			Help:      "Counter of Expensive Executors.",
		}, []string{LblType},
	)

	// StmtNodeCounter records the number of statement with the same type.
	StmtNodeCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "statement_total",
			Help:      "Counter of StmtNode.",
		}, []string{LblType})

	// DbStmtNodeCounter records the number of statement with the same type and db.
	DbStmtNodeCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "statement_db_total",
			Help:      "Counter of StmtNode by Database.",
		}, []string{LblDb, LblType})

	// ExecPhaseDuration records the duration of each execution phase.
	ExecPhaseDuration = prometheus.NewSummaryVec(
		prometheus.SummaryOpts{
			Namespace: "tidb",
			Subsystem: "executor",
			Name:      "phase_duration_seconds",
			Help:      "Summary of each execution phase duration.",
		}, []string{LblPhase, LblInternal})
)
View Source
var (
	GCWorkerCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "tikvclient",
			Name:      "gc_worker_actions_total",
			Help:      "Counter of gc worker actions.",
		}, []string{"type"})

	GCHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "tikvclient",
			Name:      "gc_seconds",
			Help:      "Bucketed histogram of gc duration.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 20),
		}, []string{"stage"})

	GCConfigGauge = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "tikvclient",
			Name:      "gc_config",
			Help:      "Gauge of GC configs.",
		}, []string{"type"})

	GCJobFailureCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "tikvclient",
			Name:      "gc_failure",
			Help:      "Counter of gc job failure.",
		}, []string{"type"})

	GCActionRegionResultCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "tikvclient",
			Name:      "gc_action_result",
			Help:      "Counter of gc action result on region level.",
		}, []string{"type"})

	GCRegionTooManyLocksCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "tikvclient",
			Name:      "gc_region_too_many_locks",
			Help:      "Counter of gc scan lock request more than once in the same region.",
		})

	GCUnsafeDestroyRangeFailuresCounterVec *prometheus.CounterVec
)

Metrics for the GC worker.

View Source
var (
	LastCheckpoint = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "tidb",
		Subsystem: "log_backup",
		Name:      "last_checkpoint",
		Help:      "The last global checkpoint of log backup.",
	}, []string{"task"})
	AdvancerOwner = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace:   "tidb",
		Subsystem:   "log_backup",
		Name:        "advancer_owner",
		Help:        "If the node is the owner of advancers, set this to `1`, otherwise `0`.",
		ConstLabels: map[string]string{},
	})
	AdvancerTickDuration = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "tidb",
		Subsystem: "log_backup",
		Name:      "advancer_tick_duration_sec",
		Help:      "The time cost of each step during advancer ticking.",
		Buckets:   prometheus.ExponentialBuckets(0.01, 3.0, 8),
	}, []string{"step"})
	GetCheckpointBatchSize = prometheus.NewHistogramVec(prometheus.HistogramOpts{
		Namespace: "tidb",
		Subsystem: "log_backup",
		Name:      "advancer_batch_size",
		Help:      "The batch size of scanning region or get region checkpoint.",
		Buckets:   prometheus.ExponentialBuckets(1, 2.0, 12),
	}, []string{"type"})
	RegionCheckpointRequest = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "tidb",
		Subsystem: "log_backup",
		Name:      "region_request",
		Help:      "The failure / success stat requesting region checkpoints.",
	}, []string{"result"})
	RegionCheckpointFailure = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "tidb",
		Subsystem: "log_backup",
		Name:      "region_request_failure",
		Help:      "The failure reasons of requesting region checkpoints.",
	}, []string{"reason"})
	RegionCheckpointSubscriptionEvent = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "tidb",
		Subsystem: "log_backup",
		Name:      "region_checkpoint_event",
		Help:      "The region flush event count.",
	}, []string{"store"})
)

log backup metrics. see the `Help` field for details.

View Source
var (
	GlobalAutoID      = "global"
	TableAutoIDAlloc  = "alloc"
	TableAutoIDRebase = "rebase"
	AutoIDHistogram   = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "autoid",
			Name:      "operation_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of handled autoid.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblType, LblResult})

	GetSchemaDiff    = "get_schema_diff"
	SetSchemaDiff    = "set_schema_diff"
	GetHistoryDDLJob = "get_history_ddl_job"

	MetaHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "meta",
			Name:      "operation_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of tidb meta data operations.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblType, LblResult})
)

Metrics

View Source
var (
	// PanicCounter measures the count of panics.
	PanicCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "panic_total",
			Help:      "Counter of panic.",
		}, []string{LblType})

	// MemoryUsage measures the usage gauge of memory.
	MemoryUsage = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "memory_usage",
			Help:      "Memory Usage",
		}, []string{LblModule, LblType})
)
View Source
var (
	NewSessionHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "owner",
			Name:      "new_session_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of new session.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 22),
		}, []string{LblType, LblResult})

	WatcherClosed     = "watcher_closed"
	Cancelled         = "cancelled"
	Deleted           = "deleted"
	SessionDone       = "session_done"
	CtxDone           = "context_done"
	WatchOwnerCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "owner",
			Name:      "watch_owner_total",
			Help:      "Counter of watch owner.",
		}, []string{LblType, LblResult})

	NoLongerOwner        = "no_longer_owner"
	CampaignOwnerCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "owner",
			Name:      "campaign_owner_total",
			Help:      "Counter of campaign owner.",
		}, []string{LblType, LblResult})
)

Metrics

View Source
var (
	PacketIOCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "packet_io_bytes",
			Help:      "Counters of packet IO bytes.",
		}, []string{LblType})

	QueryDurationHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "handle_query_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of handled queries.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblSQLType})

	QueryTotalCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "query_total",
			Help:      "Counter of queries.",
		}, []string{LblType, LblResult})

	AffectedRowsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "affected_rows",
			Help:      "Counters of server affected rows.",
		}, []string{LblSQLType})

	ConnGauge = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "connections",
			Help:      "Number of connections.",
		})

	DisconnectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "disconnection_total",
			Help:      "Counter of connections disconnected.",
		}, []string{LblResult})

	PreparedStmtGauge = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "tidb",
		Subsystem: "server",
		Name:      "prepared_stmts",
		Help:      "number of prepared statements.",
	})

	ExecuteErrorCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "execute_error_total",
			Help:      "Counter of execute errors.",
		}, []string{LblType})

	CriticalErrorCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "critical_error_total",
			Help:      "Counter of critical errors.",
		})

	EventStart        = "start"
	EventGracefulDown = "graceful_shutdown"
	// Eventkill occurs when the server.Kill() function is called.
	EventKill          = "kill"
	EventClose         = "close"
	ServerEventCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "event_total",
			Help:      "Counter of tidb-server event.",
		}, []string{LblType})

	TimeJumpBackCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "monitor",
			Name:      "time_jump_back_total",
			Help:      "Counter of system time jumps backward.",
		})

	PlanCacheCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "plan_cache_total",
			Help:      "Counter of query using plan cache.",
		}, []string{LblType})

	PlanCacheMissCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "plan_cache_miss_total",
			Help:      "Counter of plan cache miss.",
		}, []string{LblType})

	PlanCacheInstanceMemoryUsage = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "plan_cache_instance_memory_usage",
			Help:      "Total plan cache memory usage of all sessions in a instance",
		}, []string{LblType})

	PlanCacheInstancePlanNumCounter = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "plan_cache_instance_plan_num_total",
			Help:      "Counter of plan of all prepared plan cache in a instance",
		}, []string{LblType})

	ReadFromTableCacheCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "read_from_tablecache_total",
			Help:      "Counter of query read from table cache.",
		},
	)

	HandShakeErrorCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "handshake_error_total",
			Help:      "Counter of hand shake error.",
		},
	)

	GetTokenDurationHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "get_token_duration_seconds",
			Help:      "Duration (us) for getting token, it should be small until concurrency limit is reached.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 30),
		})

	NumOfMultiQueryHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "multi_query_num",
			Help:      "The number of queries contained in a multi-query statement.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 20),
		})

	TotalQueryProcHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "slow_query_process_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of of slow queries.",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		}, []string{LblSQLType})
	TotalCopProcHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "slow_query_cop_duration_seconds",
			Help:      "Bucketed histogram of all cop processing time (s) of of slow queries.",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		}, []string{LblSQLType})
	TotalCopWaitHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "slow_query_wait_duration_seconds",
			Help:      "Bucketed histogram of all cop waiting time (s) of of slow queries.",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		}, []string{LblSQLType})

	MaxProcs = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "maxprocs",
			Help:      "The value of GOMAXPROCS.",
		})

	GOGC = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "gogc",
			Help:      "The value of GOGC",
		})

	ConnIdleDurationHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "conn_idle_duration_seconds",
			Help:      "Bucketed histogram of connection idle time (s).",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblInTxn})

	ServerInfo = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "info",
			Help:      "Indicate the tidb server info, and the value is the start timestamp (s).",
		}, []string{LblVersion, LblHash})

	TokenGauge = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "tokens",
			Help:      "The number of concurrent executing session",
		},
	)

	ConfigStatus = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "config",
			Name:      "status",
			Help:      "Status of the TiDB server configurations.",
		}, []string{LblType})

	TiFlashQueryTotalCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "tiflash_query_total",
			Help:      "Counter of TiFlash queries.",
		}, []string{LblType, LblResult})

	TiFlashFailedMPPStoreState = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "tiflash_failed_store",
			Help:      "Statues of failed tiflash mpp store,-1 means detector heartbeat,0 means reachable,1 means abnormal.",
		}, []string{LblAddress})

	PDAPIExecutionHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "pd_api_execution_duration_seconds",
			Help:      "Bucketed histogram of all pd api execution time (s)",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 20),
		}, []string{LblType})

	PDAPIRequestCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "pd_api_request_total",
			Help:      "Counter of the pd http api requests",
		}, []string{LblType, LblResult})

	CPUProfileCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "cpu_profile_total",
			Help:      "Counter of cpu profiling",
		})

	LoadTableCacheDurationHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "load_table_cache_seconds",
			Help:      "Duration (us) for loading table cache.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 30),
		})

	RCCheckTSWriteConfilictCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "rc_check_ts_conflict_total",
			Help:      "Counter of WriteConflict caused by RCCheckTS.",
		}, []string{LblType})
)

Metrics

View Source
var (
	AutoIDReqDuration = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "meta",
			Name:      "autoid_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) in parse SQL.",
			Buckets:   prometheus.ExponentialBuckets(0.00004, 2, 28),
		})

	SessionExecuteParseDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "parse_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) in parse SQL.",
			Buckets:   prometheus.ExponentialBuckets(0.00004, 2, 28),
		}, []string{LblSQLType})
	SessionExecuteCompileDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "compile_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) in query optimize.",

			Buckets: prometheus.ExponentialBuckets(0.00004, 2, 28),
		}, []string{LblSQLType})
	SessionExecuteRunDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "execute_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) in running executor.",
			Buckets:   prometheus.ExponentialBuckets(0.0001, 2, 30),
		}, []string{LblSQLType})
	SchemaLeaseErrorCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "schema_lease_error_total",
			Help:      "Counter of schema lease error",
		}, []string{LblType})
	SessionRetry = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "retry_num",
			Help:      "Bucketed histogram of session retry count.",
			Buckets:   prometheus.LinearBuckets(0, 1, 21),
		})
	SessionRetryErrorCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "retry_error_total",
			Help:      "Counter of session retry error.",
		}, []string{LblSQLType, LblType})

	SessionRestrictedSQLCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "restricted_sql_total",
			Help:      "Counter of internal restricted sql.",
		})

	StatementPerTransaction = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "transaction_statement_num",
			Help:      "Bucketed histogram of statements count in each transaction.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 16),
		}, []string{LblTxnMode, LblType})

	TransactionDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "transaction_duration_seconds",
			Help:      "Bucketed histogram of a transaction execution duration, including retry.",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		}, []string{LblTxnMode, LblType})

	StatementDeadlockDetectDuration = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "statement_deadlock_detect_duration_seconds",
			Help:      "Bucketed histogram of a statement deadlock detect duration.",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		},
	)

	StatementPessimisticRetryCount = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "statement_pessimistic_retry_count",
			Help:      "Bucketed histogram of statement pessimistic retry count",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 16),
		})

	StatementLockKeysCount = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "statement_lock_keys_count",
			Help:      "Keys locking for a single statement",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 21),
		})

	ValidateReadTSFromPDCount = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "validate_read_ts_from_pd_count",
			Help:      "Counter of validating read ts by getting a timestamp from PD",
		})

	NonTransactionalDMLCount = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "non_transactional_dml_count",
			Help:      "Counter of non-transactional delete",
		}, []string{LblType},
	)
	TxnStatusEnteringCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "txn_state_entering_count",
			Help:      "How many times transactions enter this state",
		}, []string{LblType},
	)
	TxnDurationHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "txn_state_seconds",
			Help:      "Bucketed histogram of different states of a transaction.",
			Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 29),
		}, []string{LblType, LblHasLock})
	LazyPessimisticUniqueCheckSetCount = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "lazy_pessimistic_unique_check_set_count",
			Help:      "Counter of setting tidb_constraint_check_in_place to false, note that it doesn't count the default value set by tidb config",
		},
	)

	PessimisticDMLDurationByAttempt = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "session",
			Name:      "transaction_pessimistic_dml_duration_by_attempt",
			Help:      "Bucketed histogram of duration of pessimistic DMLs, distinguished by first attempt and retries",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		}, []string{LblType, LblPhase})
)

Session metrics.

View Source
var (
	// SmallTxnWriteDuration uses to collect small transaction write duration.
	SmallTxnWriteDuration = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "sli",
			Name:      "small_txn_write_duration_seconds",
			Help:      "Bucketed histogram of small transaction write time (s).",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 28),
		})

	// TxnWriteThroughput uses to collect transaction write throughput which transaction is not small.
	TxnWriteThroughput = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "sli",
			Name:      "txn_write_throughput",
			Help:      "Bucketed histogram of transaction write throughput (bytes/second).",
			Buckets:   prometheus.ExponentialBuckets(64, 1.3, 40),
		})
)
View Source
var (
	AutoAnalyzeHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "auto_analyze_duration_seconds",
			Help:      "Bucketed histogram of processing time (s) of auto analyze.",
			Buckets:   prometheus.ExponentialBuckets(0.01, 2, 24),
		})

	AutoAnalyzeCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "auto_analyze_total",
			Help:      "Counter of auto analyze.",
		}, []string{LblType})

	StatsInaccuracyRate = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "stats_inaccuracy_rate",
			Help:      "Bucketed histogram of stats inaccuracy rate.",
			Buckets:   prometheus.ExponentialBuckets(0.01, 2, 14),
		})

	PseudoEstimation = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "pseudo_estimation_total",
			Help:      "Counter of pseudo estimation caused by outdated stats.",
		}, []string{LblType})

	DumpFeedbackCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "dump_feedback_total",
			Help:      "Counter of dumping feedback.",
		}, []string{LblType})

	UpdateStatsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "update_stats_total",
			Help:      "Counter of updating stats using feedback.",
		}, []string{LblType})

	StoreQueryFeedbackCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "store_query_feedback_total",
			Help:      "Counter of storing query feedback.",
		}, []string{LblType})

	SignificantFeedbackCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "high_error_rate_feedback_total",
			Help:      "Counter of query feedback whose actual count is much different than calculated by current statistics",
		})

	FastAnalyzeHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "fast_analyze_status",
			Help:      "Bucketed histogram of some stats in fast analyze.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 16),
		}, []string{LblSQLType, LblType})

	SyncLoadCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "sync_load_total",
			Help:      "Counter of sync load.",
		})

	SyncLoadTimeoutCounter = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "sync_load_timeout_total",
			Help:      "Counter of sync load timeout.",
		})

	SyncLoadHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "sync_load_latency_millis",
			Help:      "Bucketed histogram of latency time (ms) of sync load.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 22),
		})

	ReadStatsHistogram = prometheus.NewHistogram(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "read_stats_latency_millis",
			Help:      "Bucketed histogram of latency time (ms) of stats read during sync-load.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 22),
		})

	StatsCacheLRUCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "statistics",
			Name:      "stats_cache_lru_op",
			Help:      "Counter of lru for statsCache operation",
		}, []string{LblType})

	StatsCacheLRUGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "tidb",
		Subsystem: "statistics",
		Name:      "stats_cache_lru_val",
		Help:      "gauge of stats cache lru value",
	}, []string{LblType})

	StatsHealthyGauge = prometheus.NewGaugeVec(prometheus.GaugeOpts{
		Namespace: "tidb",
		Subsystem: "statistics",
		Name:      "stats_healthy",
		Help:      "Gauge of stats healthy",
	}, []string{LblType})

	HistoricalStatsCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "tidb",
		Subsystem: "statistics",
		Name:      "historical_stats",
		Help:      "counter of the historical stats operation",
	}, []string{LblType, LblResult})

	PlanReplayerTaskCounter = prometheus.NewCounterVec(prometheus.CounterOpts{
		Namespace: "tidb",
		Subsystem: "plan_replayer",
		Name:      "task",
		Help:      "counter of plan replayer captured task",
	}, []string{LblType, LblResult})

	PlanReplayerRegisterTaskGauge = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "tidb",
		Subsystem: "plan_replayer",
		Name:      "register_task",
		Help:      "gauge of plan replayer registered task",
	})
)

Stats metrics.

View Source
var (
	TelemetrySQLCTECnt = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "non_recursive_cte_usage",
			Help:      "Counter of usage of CTE",
		}, []string{LblCTEType})
	TelemetryMultiSchemaChangeCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "multi_schema_change_usage",
			Help:      "Counter of usage of multi-schema change",
		})
	TelemetryTablePartitionCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_usage",
			Help:      "Counter of CREATE TABLE which includes of table partitioning",
		})
	TelemetryTablePartitionListCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_list_usage",
			Help:      "Counter of CREATE TABLE which includes LIST partitioning",
		})
	TelemetryTablePartitionRangeCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_range_usage",
			Help:      "Counter of CREATE TABLE which includes RANGE partitioning",
		})
	TelemetryTablePartitionHashCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_hash_usage",
			Help:      "Counter of CREATE TABLE which includes HASH partitioning",
		})
	TelemetryTablePartitionRangeColumnsCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_range_columns_usage",
			Help:      "Counter of CREATE TABLE which includes RANGE COLUMNS partitioning",
		})
	TelemetryTablePartitionRangeColumnsGt1Cnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_range_multi_columns_usage",
			Help:      "Counter of CREATE TABLE which includes RANGE COLUMNS partitioning with more than one partitioning column",
		})
	TelemetryTablePartitionRangeColumnsGt2Cnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_range_multi_columns_usage",
			Help:      "Counter of CREATE TABLE which includes RANGE COLUMNS partitioning with more than two partitioning columns",
		})
	TelemetryTablePartitionRangeColumnsGt3Cnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_range_multi_columns_usage",
			Help:      "Counter of CREATE TABLE which includes RANGE COLUMNS partitioning with more than three partitioning columns",
		})
	TelemetryTablePartitionListColumnsCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_list_columns_usage",
			Help:      "Counter of CREATE TABLE which includes LIST COLUMNS partitioning",
		})
	TelemetryTablePartitionMaxPartitionsCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_max_partition_usage",
			Help:      "Counter of partitions created by CREATE TABLE statements",
		})
	TelemetryAccountLockCnt = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "account_lock_usage",
			Help:      "Counter of locked/unlocked users",
		}, []string{LblAccountLock})
	TelemetryTablePartitionCreateIntervalPartitionsCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_create_interval_partition_usage",
			Help:      "Counter of partitions created by CREATE TABLE INTERVAL statements",
		})
	TelemetryTablePartitionAddIntervalPartitionsCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_add_interval_partition_usage",
			Help:      "Counter of partitions added by ALTER TABLE LAST PARTITION statements",
		})
	TelemetryTablePartitionDropIntervalPartitionsCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "table_partition_drop_interval_partition_usage",
			Help:      "Counter of partitions added by ALTER TABLE FIRST PARTITION statements",
		})
	TelemetryExchangePartitionCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "exchange_partition_usage",
			Help:      "Counter of usage of exchange partition statements",
		})
	TelemetryAddIndexIngestCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "add_index_ingest_usage",
			Help:      "Counter of usage of add index acceleration solution",
		})
	TelemetryFlashbackClusterCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "flashback_cluster_usage",
			Help:      "Counter of usage of flashback cluster",
		})
	TelemetryIndexMergeUsage = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "index_merge_usage",
			Help:      "Counter of usage of index merge",
		})
	TelemetryCompactPartitionCnt = prometheus.NewCounter(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "telemetry",
			Name:      "compact_partition_usage",
			Help:      "Counter of compact table partition",
		})
)

Metrics

View Source
var (
	TopSQLIgnoredCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "topsql",
			Name:      "ignored_total",
			Help:      "Counter of ignored top-sql metrics (register-sql, register-plan, collect-data and report-data), normally it should be 0.",
		}, []string{LblType})

	TopSQLReportDurationHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "topsql",
			Name:      "report_duration_seconds",
			Help:      "Bucket histogram of reporting time (s) to the top-sql agent",
			Buckets:   prometheus.ExponentialBuckets(0.001, 2, 24),
		}, []string{LblType, LblResult})

	TopSQLReportDataHistogram = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "topsql",
			Name:      "report_data_total",
			Help:      "Bucket histogram of reporting records/sql/plan count to the top-sql agent.",
			Buckets:   prometheus.ExponentialBuckets(1, 2, 20),
		}, []string{LblType})
)

Top SQL metrics.

View Source
var (
	TTLQueryDuration = prometheus.NewHistogramVec(
		prometheus.HistogramOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "ttl_query_duration",
			Help:      "Bucketed histogram of processing time (s) of handled TTL queries.",
			Buckets:   prometheus.ExponentialBuckets(0.01, 2, 20),
		}, []string{LblSQLType, LblResult})

	TTLProcessedExpiredRowsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "ttl_processed_expired_rows",
			Help:      "The count of expired rows processed in TTL jobs",
		}, []string{LblSQLType, LblResult})

	TTLJobStatus = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "ttl_job_status",
			Help:      "The jobs count in the specified status",
		}, []string{LblType})

	TTLPhaseTime = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "tidb",
			Subsystem: "server",
			Name:      "ttl_phase_time",
			Help:      "The time spent in each phase",
		}, []string{LblType, LblPhase})
)

TTL metrics

View Source
var (
	// EMACPUUsageGauge means exponential moving average of CPU usage
	EMACPUUsageGauge = prometheus.NewGauge(prometheus.GaugeOpts{
		Namespace: "tidb",
		Subsystem: "rm",
		Name:      "ema_cpu_usage",
		Help:      "exponential moving average of CPU usage",
	})
)
View Source
var (
	// ResettablePlanCacheCounterFortTest be used to support reset counter in test.
	ResettablePlanCacheCounterFortTest = false
)

Functions

func ExecuteErrorToLabel

func ExecuteErrorToLabel(err error) string

ExecuteErrorToLabel converts an execute error to label.

func GenerateReorgLabel

func GenerateReorgLabel(label string, schemaName string, tableName string) string

GenerateReorgLabel returns the label with schema name and table name.

func GetBackfillProgressByLabel

func GetBackfillProgressByLabel(label string, schemaName string, tableName string) prometheus.Gauge

GetBackfillProgressByLabel returns the Gauge showing the percentage progress for the given type label.

func GetLazyPessimisticUniqueCheckSetCounter

func GetLazyPessimisticUniqueCheckSetCounter() int64

GetLazyPessimisticUniqueCheckSetCounter returns the counter of setting tidb_constraint_check_in_place_pessimistic to false.

func GetSavepointStmtCounter

func GetSavepointStmtCounter() int64

GetSavepointStmtCounter gets the savepoint statement executed counter.

func RegisterMetrics

func RegisterMetrics()

RegisterMetrics registers the metrics which are ONLY used in TiDB server.

func RetLabel

func RetLabel(err error) string

RetLabel returns "ok" when err == nil and "err" when err != nil. This could be useful when you need to observe the operation result.

func ToggleSimplifiedMode

func ToggleSimplifiedMode(simplified bool)

ToggleSimplifiedMode is used to register/unregister the metrics that unused by grafana.

Types

type AccountLockCounter

type AccountLockCounter struct {
	LockUser          int64 `json:"lockUser"`
	UnlockUser        int64 `json:"unlockUser"`
	CreateOrAlterUser int64 `json:"createOrAlterUser"`
}

AccountLockCounter records the number of lock users/roles

func GetAccountLockCounter

func GetAccountLockCounter() AccountLockCounter

GetAccountLockCounter gets the AccountLockCounter

func (AccountLockCounter) Sub

Sub returns the difference of two counters.

type CTEUsageCounter

type CTEUsageCounter struct {
	NonRecursiveCTEUsed int64 `json:"nonRecursiveCTEUsed"`
	RecursiveUsed       int64 `json:"recursiveUsed"`
	NonCTEUsed          int64 `json:"nonCTEUsed"`
}

CTEUsageCounter records the usages of CTE.

func GetCTECounter

func GetCTECounter() CTEUsageCounter

GetCTECounter gets the TxnCommitCounter.

func (CTEUsageCounter) Sub

Sub returns the difference of two counters.

type DDLUsageCounter

type DDLUsageCounter struct {
	AddIndexIngestUsed   int64 `json:"add_index_ingest_used"`
	MetadataLockUsed     bool  `json:"metadata_lock_used"`
	FlashbackClusterUsed int64 `json:"flashback_cluster_used"`
}

DDLUsageCounter records the usages of DDL related features.

func GetDDLUsageCounter

func GetDDLUsageCounter() DDLUsageCounter

GetDDLUsageCounter gets the add index acceleration solution counts.

func (DDLUsageCounter) Sub

Sub returns the difference of two counters.

type ExchangePartitionUsageCounter

type ExchangePartitionUsageCounter struct {
	ExchangePartitionCnt int64 `json:"exchange_partition_cnt"`
}

ExchangePartitionUsageCounter records the usages of exchange partition.

func GetExchangePartitionCounter

func GetExchangePartitionCounter() ExchangePartitionUsageCounter

GetExchangePartitionCounter gets the TxnCommitCounter.

func (ExchangePartitionUsageCounter) Sub

Sub returns the difference of two counters.

type IndexMergeUsageCounter

type IndexMergeUsageCounter struct {
	IndexMergeUsed int64 `json:"index_merge_used"`
}

IndexMergeUsageCounter records the usages of IndexMerge feature.

func GetIndexMergeCounter

func GetIndexMergeCounter() IndexMergeUsageCounter

GetIndexMergeCounter gets the IndexMerge usage counter.

func (IndexMergeUsageCounter) Sub

Sub returns the difference of two counters.

type MultiSchemaChangeUsageCounter

type MultiSchemaChangeUsageCounter struct {
	MultiSchemaChangeUsed int64 `json:"multi_schema_change_used"`
}

MultiSchemaChangeUsageCounter records the usages of multi-schema change.

func GetMultiSchemaCounter

func GetMultiSchemaCounter() MultiSchemaChangeUsageCounter

GetMultiSchemaCounter gets the TxnCommitCounter.

func (MultiSchemaChangeUsageCounter) Sub

Sub returns the difference of two counters.

type NonTransactionalStmtCounter

type NonTransactionalStmtCounter struct {
	DeleteCount int64 `json:"delete"`
	UpdateCount int64 `json:"update"`
	InsertCount int64 `json:"insert"`
}

NonTransactionalStmtCounter records the usages of non-transactional statements.

func GetNonTransactionalStmtCounter

func GetNonTransactionalStmtCounter() NonTransactionalStmtCounter

GetNonTransactionalStmtCounter gets the NonTransactionalStmtCounter.

func (NonTransactionalStmtCounter) Sub

Sub returns the difference of two counters.

type TablePartitionUsageCounter

type TablePartitionUsageCounter struct {
	TablePartitionCnt                         int64 `json:"table_partition_cnt"`
	TablePartitionListCnt                     int64 `json:"table_partition_list_cnt"`
	TablePartitionRangeCnt                    int64 `json:"table_partition_range_cnt"`
	TablePartitionHashCnt                     int64 `json:"table_partition_hash_cnt"`
	TablePartitionRangeColumnsCnt             int64 `json:"table_partition_range_columns_cnt"`
	TablePartitionRangeColumnsGt1Cnt          int64 `json:"table_partition_range_columns_gt_1_cnt"`
	TablePartitionRangeColumnsGt2Cnt          int64 `json:"table_partition_range_columns_gt_2_cnt"`
	TablePartitionRangeColumnsGt3Cnt          int64 `json:"table_partition_range_columns_gt_3_cnt"`
	TablePartitionListColumnsCnt              int64 `json:"table_partition_list_columns_cnt"`
	TablePartitionMaxPartitionsCnt            int64 `json:"table_partition_max_partitions_cnt"`
	TablePartitionCreateIntervalPartitionsCnt int64 `json:"table_partition_create_interval_partitions_cnt"`
	TablePartitionAddIntervalPartitionsCnt    int64 `json:"table_partition_add_interval_partitions_cnt"`
	TablePartitionDropIntervalPartitionsCnt   int64 `json:"table_partition_drop_interval_partitions_cnt"`
	TablePartitionComactCnt                   int64 `json:"table_TablePartitionComactCnt"`
}

TablePartitionUsageCounter records the usages of table partition.

func GetTablePartitionCounter

func GetTablePartitionCounter() TablePartitionUsageCounter

GetTablePartitionCounter gets the TxnCommitCounter.

func ResetTablePartitionCounter

func ResetTablePartitionCounter(pre TablePartitionUsageCounter) TablePartitionUsageCounter

ResetTablePartitionCounter gets the TxnCommitCounter.

func (TablePartitionUsageCounter) Cal

Cal returns the difference of two counters.

Jump to

Keyboard shortcuts

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