Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#10553
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
  • Loading branch information
sdojjy authored and ti-chi-bot committed Mar 11, 2024
1 parent 5df9142 commit e0754fc
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cdc/server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/pingcap/tiflow/pkg/orchestrator"
"github.com/pingcap/tiflow/pkg/p2p"
"github.com/pingcap/tiflow/pkg/sink/observer"
"github.com/pingcap/tiflow/pkg/txnutil/gc"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
tikvmetrics "github.com/tikv/client-go/v2/metrics"
Expand Down Expand Up @@ -55,6 +56,7 @@ func init() {
redo.InitMetrics(registry)
scheduler.InitMetrics(registry)
observer.InitMetrics(registry)
gc.InitMetrics(registry)
// TiKV client metrics, including metrics about resolved and region cache.
originalRegistry := prometheus.DefaultRegisterer
prometheus.DefaultRegisterer = registry
Expand Down
115 changes: 112 additions & 3 deletions metrics/grafana/ticdc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3076,7 +3076,7 @@
},
"gridPos": {
"h": 7,
"w": 12,
"w": 6,
"x": 0,
"y": 3
},
Expand Down Expand Up @@ -3133,8 +3133,8 @@
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"w": 6,
"x": 6,
"y": 3
},
"hiddenSeries": false,
Expand Down Expand Up @@ -3226,6 +3226,111 @@
"alignLevel": null
}
},
{
"aliasColors": {},
"bars": false,
"dashLength": 10,
"dashes": false,
"datasource": "${DS_TEST-CLUSTER}",
"fieldConfig": {
"defaults": {
"unit": "dateTimeAsIso"
},
"overrides": []
},
"fill": 1,
"fillGradient": 0,
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"y": 3
},
"hiddenSeries": false,
"id": 10037,
"legend": {
"avg": false,
"current": true,
"max": false,
"min": false,
"show": true,
"total": false,
"values": true
},
"lines": true,
"linewidth": 1,
"nullPointMode": "null",
"options": {
"alertThreshold": true
},
"percentage": false,
"pluginVersion": "7.5.10",
"pointradius": 2,
"points": false,
"renderer": "flot",
"seriesOverrides": [],
"spaceLength": 10,
"stack": false,
"steppedLine": false,
"targets": [
{
"exemplar": true,
"expr": "max(ticdc_gc_min_service_gc_safepoint{})",
"interval": "",
"legendFormat": "gc time",
"queryType": "randomWalk",
"refId": "A"
},
{
"exemplar": true,
"expr": "max(ticdc_gc_cdc_gc_safepoint{})",
"hide": false,
"interval": "",
"legendFormat": "cdc service safepoint",
"refId": "B"
}
],
"thresholds": [],
"timeFrom": null,
"timeRegions": [],
"timeShift": null,
"title": "GC Time",
"tooltip": {
"shared": true,
"sort": 0,
"value_type": "individual"
},
"type": "graph",
"xaxis": {
"buckets": null,
"mode": "time",
"name": null,
"show": true,
"values": []
},
"yaxes": [
{
"format": "dateTimeAsIso",
"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": {},
"bars": true,
Expand Down Expand Up @@ -19807,5 +19912,9 @@
"timezone": "browser",
"title": "${DS_TEST-CLUSTER}-TiCDC",
"uid": "YiGL8hBZ1",
<<<<<<< HEAD
"version": 52
=======
"version": 57
>>>>>>> 0424aba6e4 (gc(ticdc): add min service gc safe point metrics (#10553))
}
2 changes: 2 additions & 0 deletions pkg/txnutil/gc/gc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ func (m *gcManager) TryUpdateGCSafePoint(
m.isTiCDCBlockGC = actual == checkpointTs
m.lastSafePointTs = actual
m.lastSucceededTime = time.Now()
minServiceGCSafePointGauge.Set(float64(oracle.ExtractPhysical(actual)))
cdcGCSafePointGauge.Set(float64(oracle.ExtractPhysical(checkpointTs)))
return nil
}

Expand Down
42 changes: 42 additions & 0 deletions pkg/txnutil/gc/metrics.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2020 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.

package gc

import (
"github.com/prometheus/client_golang/prometheus"
)

var (
minServiceGCSafePointGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "ticdc",
Subsystem: "gc",
Name: "min_service_gc_safepoint",
Help: "The min value all of service GC safepoint",
})

cdcGCSafePointGauge = prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: "ticdc",
Subsystem: "gc",
Name: "cdc_gc_safepoint",
Help: "the value of CDC GC safepoint",
})
)

// InitMetrics registers all metrics used gc manager
func InitMetrics(registry *prometheus.Registry) {
registry.MustRegister(minServiceGCSafePointGauge)
registry.MustRegister(cdcGCSafePointGauge)
}

0 comments on commit e0754fc

Please sign in to comment.