Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gc(ticdc): add min service gc safe point metrics #10553

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
113 changes: 109 additions & 4 deletions metrics/grafana/ticdc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3086,7 +3086,7 @@
},
"gridPos": {
"h": 7,
"w": 12,
"w": 6,
"x": 0,
"y": 3
},
Expand Down Expand Up @@ -3144,8 +3144,8 @@
"grid": {},
"gridPos": {
"h": 7,
"w": 12,
"x": 12,
"w": 6,
"x": 6,
"y": 3
},
"hiddenSeries": false,
Expand Down Expand Up @@ -3237,6 +3237,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 @@ -21661,4 +21766,4 @@
"title": "${DS_TEST-CLUSTER}-TiCDC",
"uid": "YiGL8hBZ1",
"version": 57
}
}
2 changes: 2 additions & 0 deletions pkg/txnutil/gc/gc_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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)

Check warning on line 41 in pkg/txnutil/gc/metrics.go

View check run for this annotation

Codecov / codecov/patch

pkg/txnutil/gc/metrics.go#L39-L41

Added lines #L39 - L41 were not covered by tests
}
Loading