tidb: github.com/pingcap/tidb/metrics Index | Files

package metrics

import "github.com/pingcap/tidb/metrics"

Index

Package Files

bindinfo.go ddl.go distsql.go domain.go executor.go gc_worker.go gprc.go meta.go metrics.go oracles.go owner.go server.go session.go stats.go tikvclient.go

Constants

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

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

    LableScope   = "scope"
    ScopeGlobal  = "global"
    ScopeSession = "session"
)

metrics labels.

const (
    LblUnretryable = "unretryable"
    LblReachMax    = "reach_max"
    LblOK          = "ok"
    LblError       = "error"
    LblRollback    = "rollback"
    LblType        = "type"
    LblDb          = "db"
    LblResult      = "result"
    LblSQLType     = "sql_type"
    LblGeneral     = "general"
    LblInternal    = "internal"
    LblStore       = "store"
    LblAddress     = "address"
)

Label constants.

const (
    LblAction = "action"
)

Label constants.

Variables

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

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

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

bindinfo metrics.

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, 22),
        }, []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, 22),
        }, []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"
    OwnerGetGlobalVersion       = "get_global_version"
    OwnerCheckAllVersions       = "check_all_versions"
    OwnerNotifyCleanExpirePaths = "notify_clean_expire_paths"
    OwnerCleanExpirePaths       = "clean_expire_paths"
    OwnerCleanOneExpirePath     = "clean_an_expire_path"
    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.
    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, 22),
        }, []string{LblType, LblAction, LblResult})

    CreateDDLInstance = "create_ddl_instance"
    CreateDDL         = "create_ddl"
    StartCleanWork    = "start_clean_work"
    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})
)

Metrics for the DDL package.

var (
    DistSQLQueryHistgram = 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, 18),
        }, []string{LblType, LblSQLType})

    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.",
        },
    )
)

distsql metrics.

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),
        })

    // 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})
)
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})
)
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.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "gc_unsafe_destroy_range_failures",
            Help:      "Counter of unsafe destroyrange failures",
        }, []string{"type"})
)

Metrics for the GC worker.

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, 22),
        }, []string{LblType, LblResult})

    GetSchemaDiff    = "get_schema_diff"
    SetSchemaDiff    = "set_schema_diff"
    GetDDLJobByIdx   = "get_ddl_job"
    UpdateDDLJob     = "update_ddl_job"
    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, 22),
        }, []string{LblType, LblResult})
)

Metrics

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

var (
    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, 22),
        }, []string{LblSQLType})

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

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

    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"
    // EventHang occurs when server meet some critical error. It will close the listening port and hang for ever.
    EventHang          = "hang"
    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.",
        })

    KeepAliveCounter = prometheus.NewCounter(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "monitor",
            Name:      "keep_alive_total",
            Help:      "Counter of TiDB keep alive.",
        })

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

    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, 26),
        })

    TotalQueryProcHistogram = prometheus.NewHistogram(
        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, 22),
        })
    TotalCopProcHistogram = prometheus.NewHistogram(
        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, 22),
        })
    TotalCopWaitHistogram = prometheus.NewHistogram(
        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, 22),
        })

    CPUUsagePercentageGauge = prometheus.NewGauge(
        prometheus.GaugeOpts{
            Namespace: "tidb",
            Subsystem: "server",
            Name:      "cpu_usage",
            Help:      "Percentage of CPU usage.",
        })
)

Metrics

var (
    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, 22),
        }, []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, 22),
        }, []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, 22),
        }, []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, 20),
        })
    SessionRetryErrorCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "session",
            Name:      "retry_error_total",
            Help:      "Counter of session retry error.",
        }, []string{LblSQLType, LblType})
    TransactionCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "session",
            Name:      "transaction_total",
            Help:      "Counter of transactions.",
        }, []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{LblSQLType, 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, 20),
        }, []string{LblSQLType, LblType})
)

Session metrics.

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, 20),
        })

    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.NewCounter(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "statistics",
            Name:      "pseudo_estimation_total",
            Help:      "Counter of pseudo estimation caused by outdated stats.",
        })

    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})
)

Stats metrics.

var (
    TiKVTxnCounter = prometheus.NewCounter(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "txn_total",
            Help:      "Counter of created txns.",
        })

    TiKVSnapshotCounter = prometheus.NewCounter(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "snapshot_total",
            Help:      "Counter of snapshots.",
        })

    TiKVTxnCmdCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "txn_cmd_total",
            Help:      "Counter of txn commands.",
        }, []string{LblType})

    TiKVTxnCmdHistogram = prometheus.NewHistogramVec(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "txn_cmd_duration_seconds",
            Help:      "Bucketed histogram of processing time of txn cmds.",
            Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 20),
        }, []string{LblType})

    TiKVBackoffCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "backoff_total",
            Help:      "Counter of backoff.",
        }, []string{LblType})

    TiKVBackoffHistogram = prometheus.NewHistogramVec(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "backoff_seconds",
            Help:      "total backoff seconds of a single backoffer.",
            Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 20),
        }, []string{LblType})

    TiKVSendReqHistogram = prometheus.NewHistogramVec(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "request_seconds",
            Help:      "Bucketed histogram of sending request duration.",
            Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 20),
        }, []string{LblType, LblStore})

    TiKVCoprocessorHistogram = prometheus.NewHistogram(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "cop_duration_seconds",
            Help:      "Run duration of a single coprocessor task, includes backoff time.",
            Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 20),
        })

    TiKVLockResolverCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "lock_resolver_actions_total",
            Help:      "Counter of lock resolver actions.",
        }, []string{LblType})

    TiKVRegionErrorCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "region_err_total",
            Help:      "Counter of region errors.",
        }, []string{LblType})

    TiKVTxnWriteKVCountHistogram = prometheus.NewHistogram(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "txn_write_kv_num",
            Help:      "Count of kv pairs to write in a transaction.",
            Buckets:   prometheus.ExponentialBuckets(1, 2, 21),
        })

    TiKVTxnWriteSizeHistogram = prometheus.NewHistogram(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "txn_write_size_bytes",
            Help:      "Size of kv pairs to write in a transaction.",
            Buckets:   prometheus.ExponentialBuckets(1, 2, 30),
        })

    TiKVRawkvCmdHistogram = prometheus.NewHistogramVec(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "rawkv_cmd_seconds",
            Help:      "Bucketed histogram of processing time of rawkv cmds.",
            Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 20),
        }, []string{LblType})

    TiKVRawkvSizeHistogram = prometheus.NewHistogramVec(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "rawkv_kv_size_bytes",
            Help:      "Size of key/value to put, in bytes.",
            Buckets:   prometheus.ExponentialBuckets(1, 2, 23),
        }, []string{LblType})

    TiKVTxnRegionsNumHistogram = prometheus.NewHistogramVec(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "txn_regions_num",
            Help:      "Number of regions in a transaction.",
            Buckets:   prometheus.ExponentialBuckets(1, 2, 20),
        }, []string{LblType})

    TiKVLoadSafepointCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "load_safepoint_total",
            Help:      "Counter of load safepoint.",
        }, []string{LblType})

    TiKVSecondaryLockCleanupFailureCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "lock_cleanup_task_total",
            Help:      "failure statistic of secondary lock cleanup task.",
        }, []string{LblType})

    TiKVRegionCacheCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "region_cache_operations_total",
            Help:      "Counter of region cache.",
        }, []string{LblType, LblResult})

    TiKVLocalLatchWaitTimeHistogram = prometheus.NewHistogram(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "local_latch_wait_seconds",
            Help:      "Wait time of a get local latch.",
            Buckets:   prometheus.ExponentialBuckets(0.0005, 2, 20),
        })

    // TiKVPendingBatchRequests indicates the number of requests pending in the batch channel.
    TiKVPendingBatchRequests = prometheus.NewGaugeVec(
        prometheus.GaugeOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "pending_batch_requests",
            Help:      "Pending batch requests",
        }, []string{"store"})

    TiKVBatchWaitDuration = prometheus.NewHistogram(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "batch_wait_duration",
            Buckets:   prometheus.ExponentialBuckets(1, 2, 30),
            Help:      "batch wait duration",
        })

    TiKVBatchClientUnavailable = prometheus.NewHistogram(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "batch_client_unavailable_seconds",
            Buckets:   prometheus.ExponentialBuckets(0.001, 2, 20),
            Help:      "batch client unavailable",
        })

    TiKVRangeTaskStats = prometheus.NewGaugeVec(
        prometheus.GaugeOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "range_task_stats",
            Help:      "stat of range tasks",
        }, []string{LblType, LblResult})

    TiKVRangeTaskPushDuration = prometheus.NewHistogramVec(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "range_task_push_duration",

            Buckets: prometheus.ExponentialBuckets(0.001, 2, 20),
            Help:    "duration to push sub tasks to range task workers",
        }, []string{LblType})
    TiKVTokenWaitDuration = prometheus.NewHistogram(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "tikvclient",
            Name:      "batch_executor_token_wait_duration",
            Buckets:   prometheus.ExponentialBuckets(1, 2, 30),
            Help:      "tidb txn token wait duration to process batches",
        })
)

TiKVClient metrics.

var (
    GRPCConnTransientFailureCounter = prometheus.NewCounterVec(
        prometheus.CounterOpts{
            Namespace: "tidb",
            Subsystem: "grpc",
            Name:      "connection_transient_failure_count",
            Help:      "Counter of gRPC connection transient failure",
        }, []string{LblAddress, LblStore})
)

Metrics to monitor gRPC service

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})
)
var (
    // ResettablePlanCacheCounterFortTest be used to support reset counter in test.
    ResettablePlanCacheCounterFortTest = false
)
var (
    TSFutureWaitDuration = prometheus.NewHistogram(
        prometheus.HistogramOpts{
            Namespace: "tidb",
            Subsystem: "pdclient",
            Name:      "ts_future_wait_seconds",
            Help:      "Bucketed histogram of seconds cost for waiting timestamp future.",
            Buckets:   prometheus.ExponentialBuckets(0.000005, 2, 20),
        })
)

Metrics for the timestamp oracle.

func ExecuteErrorToLabel Uses

func ExecuteErrorToLabel(err error) string

ExecuteErrorToLabel converts an execute error to label.

func RegisterMetrics Uses

func RegisterMetrics()

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

func RetLabel Uses

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.

Package metrics imports 4 packages (graph) and is imported by 116 packages. Updated 2019-09-19. Refresh now. Tools for package owners.