Skip to content

Commit

Permalink
This is an automated cherry-pick of #56272
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
tiancaiamao authored and ti-chi-bot committed Sep 26, 2024
1 parent 8e57797 commit 66656de
Show file tree
Hide file tree
Showing 4 changed files with 253 additions and 0 deletions.
212 changes: 212 additions & 0 deletions pkg/metrics/grafana/tidb.json
Original file line number Diff line number Diff line change
Expand Up @@ -3787,7 +3787,219 @@
"align": false,
"alignLevel": null
}
<<<<<<< HEAD
}
=======
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_TEST-CLUSTER}",
"description": "TiDB processing handshake error count",
"fieldConfig": {
"defaults": {},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 59
},
"hiddenSeries": false,
"id": 167,
"legend": {
"alignAsTable": true,
"avg": false,
"current": false,
"max": false,
"min": false,
"rightSide": true,
"show": true,
"total": false,
"values": false
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.5.11",
"pointradius": 5,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"expr": "sum(increase(tidb_server_handshake_error_total{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\"}[1m])) by (instance)",
"format": "time_series",
"intervalFactor": 2,
"legendFormat": "{{instance}}",
"refId": "A"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "Handshake Error OPS",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
},
{
"format": "short",
"label": null,
"logBase": 1,
"max": null,
"min": null,
"show": true
}
],
"yaxis": {
"align": false,
"alignLevel": null
}
},
{
"aliasColors": {},
"dashLength": 10,
"datasource": "${DS_TEST-CLUSTER}",
"description": "The total count of internal sessions.",
"editable": true,
"fieldConfig": {
"defaults": {},
"overrides": []
},
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 66
},
"id": 23763572016,
"legend": {
"alignAsTable": true,
"avg": false,
"current": true,
"hideEmpty": true,
"hideZero": false,
"max": true,
"min": false,
"rightSide": true,
"show": true,
"sideWidth": null,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"links": [],
"nullPointMode": "null as zero",
"options": {
"alertThreshold": true
},
"pluginVersion": "7.5.11",
"pointradius": 5,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"targets": [
{
"expr": "tidb_server_internal_sessions{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", job=\"tidb\"}",
"legendFormat": "{{instance}}",
"interval": "",
"exemplar": true,
"format": "time_series",
"hide": false,
"intervalFactor": 1,
"refId": "H"
}
],
"thresholds": [],
"timeRegions": [],
"title": "Internal Sessions",
"tooltip": {
"msResolution": true,
"shared": true,
"sort": 0,
"value_type": "cumulative"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "short",
"label": "",
"logBase": 1,
"max": null,
"min": "0",
"show": true,
"$$hashKey": "object:264"
},
{
"format": "short",
"label": "",
"logBase": 1,
"max": null,
"min": null,
"show": false,
"$$hashKey": "object:265"
}
],
"yaxis": {
"align": false,
"alignLevel": null
},
"timeFrom": null,
"timeShift": null,
"bars": false,
"dashes": false,
"error": false,
"fill": 0,
"fillGradient": 0,
"hiddenSeries": false,
"percentage": false,
"points": false,
"stack": false,
"steppedLine": false
}
>>>>>>> f988947aad2 (server,metrics: add a metrics for internal session count (#56272))
],
"repeat": null,
"title": "Server",
Expand Down
15 changes: 15 additions & 0 deletions pkg/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,21 @@ func RegisterMetrics() {
prometheus.MustRegister(GlobalSortIngestWorkerCnt)
prometheus.MustRegister(AddIndexScanRate)

<<<<<<< HEAD
=======
prometheus.MustRegister(InfoSchemaV2CacheCounter)
prometheus.MustRegister(InfoSchemaV2CacheMemUsage)
prometheus.MustRegister(InfoSchemaV2CacheMemLimit)
prometheus.MustRegister(TableByNameDuration)

prometheus.MustRegister(BindingCacheHitCounter)
prometheus.MustRegister(BindingCacheMissCounter)
prometheus.MustRegister(BindingCacheMemUsage)
prometheus.MustRegister(BindingCacheMemLimit)
prometheus.MustRegister(BindingCacheNumBindings)
prometheus.MustRegister(InternalSessions)

>>>>>>> f988947aad2 (server,metrics: add a metrics for internal session count (#56272))
tikvmetrics.InitMetrics(TiDB, TiKVClient)
tikvmetrics.RegisterMetrics()
tikvmetrics.TiKVPanicCounter = PanicCounter // reset tidb metrics for tikv metrics
Expand Down
24 changes: 24 additions & 0 deletions pkg/metrics/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ var (
CPUProfileCounter prometheus.Counter
LoadTableCacheDurationHistogram prometheus.Histogram
RCCheckTSWriteConfilictCounter *prometheus.CounterVec
<<<<<<< HEAD
=======
MemoryLimit prometheus.Gauge
InternalSessions prometheus.Gauge
>>>>>>> f988947aad2 (server,metrics: add a metrics for internal session count (#56272))
)

// InitServerMetrics initializes server metrics.
Expand Down Expand Up @@ -373,6 +378,25 @@ func InitServerMetrics() {
Name: "rc_check_ts_conflict_total",
Help: "Counter of WriteConflict caused by RCCheckTS.",
}, []string{LblType})
<<<<<<< HEAD
=======

MemoryLimit = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "memory_quota_bytes",
Help: "The value of memory quota bytes.",
})

InternalSessions = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "tidb",
Subsystem: "server",
Name: "internal_sessions",
Help: "The total count of internal sessions.",
})
>>>>>>> f988947aad2 (server,metrics: add a metrics for internal session count (#56272))
}

// ExecuteErrorToLabel converts an execute error to label.
Expand Down
2 changes: 2 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ func (s *Server) GetAutoAnalyzeProcID() uint64 {
func (s *Server) StoreInternalSession(se interface{}) {
s.sessionMapMutex.Lock()
s.internalSessions[se] = struct{}{}
metrics.InternalSessions.Set(float64(len(s.internalSessions)))
s.sessionMapMutex.Unlock()
}

Expand All @@ -1043,6 +1044,7 @@ func (s *Server) StoreInternalSession(se interface{}) {
func (s *Server) DeleteInternalSession(se interface{}) {
s.sessionMapMutex.Lock()
delete(s.internalSessions, se)
metrics.InternalSessions.Set(float64(len(s.internalSessions)))
s.sessionMapMutex.Unlock()
}

Expand Down

0 comments on commit 66656de

Please sign in to comment.