diff --git a/cdc/server/metrics.go b/cdc/server/metrics.go index 3812ecd2cd8..2ad34731907 100644 --- a/cdc/server/metrics.go +++ b/cdc/server/metrics.go @@ -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" @@ -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 diff --git a/metrics/grafana/ticdc.json b/metrics/grafana/ticdc.json index 037feac7737..3ff37dfc891 100644 --- a/metrics/grafana/ticdc.json +++ b/metrics/grafana/ticdc.json @@ -3202,7 +3202,7 @@ }, "gridPos": { "h": 7, - "w": 12, + "w": 6, "x": 0, "y": 3 }, @@ -3260,8 +3260,8 @@ "grid": {}, "gridPos": { "h": 7, - "w": 12, - "x": 12, + "w": 6, + "x": 6, "y": 3 }, "hiddenSeries": false, @@ -3353,6 +3353,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, @@ -21777,4 +21882,4 @@ "title": "${DS_TEST-CLUSTER}-TiCDC", "uid": "YiGL8hBZ1", "version": 57 -} \ No newline at end of file +} diff --git a/pkg/txnutil/gc/gc_manager.go b/pkg/txnutil/gc/gc_manager.go index 7d5619e3d55..7197e7bf4c4 100644 --- a/pkg/txnutil/gc/gc_manager.go +++ b/pkg/txnutil/gc/gc_manager.go @@ -103,6 +103,8 @@ func (m *gcManager) TryUpdateGCSafePoint( m.isTiCDCBlockGC.Store(actual == checkpointTs) m.lastSafePointTs = actual m.lastSucceededTime = time.Now() + minServiceGCSafePointGauge.Set(float64(oracle.ExtractPhysical(actual))) + cdcGCSafePointGauge.Set(float64(oracle.ExtractPhysical(checkpointTs))) return nil } diff --git a/pkg/txnutil/gc/metrics.go b/pkg/txnutil/gc/metrics.go new file mode 100644 index 00000000000..eb29c88a390 --- /dev/null +++ b/pkg/txnutil/gc/metrics.go @@ -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) +}