Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 1 addition & 1 deletion cmd/cdc/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (o *options) run(cmd *cobra.Command) error {
logger.StartLogFileMonitor(ctx, loggerConfig.File, 30*time.Second)

version.LogVersionInfo("Change Data Capture (CDC)")
metrics.BuildInfo.WithLabelValues(version.ReleaseVersion, version.GitHash, version.BuildTS, kerneltype.Name()).Set(1)
metrics.BuildInfo.WithLabelValues(version.ReleaseVersion, version.GitHash, version.BuildTS, kerneltype.Name(), "newarch").Set(1)
log.Info("The TiCDC release version", zap.String("ReleaseVersion", version.ReleaseVersion))

util.LogHTTPProxies()
Expand Down
13 changes: 7 additions & 6 deletions metrics/grafana/ticdc_new_arch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3540,7 +3540,7 @@
"pluginVersion": "7.5.17",
"targets": [
{
"expr": "max by (instance, kernel_type, git_hash, release_version, utc_build_time) (ticdc_server_build_info{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", job=~\".*ticdc.*\", instance=~\"$ticdc_instance\"})",
"expr": "max by (instance, ticdc_arch, kernel_type, git_hash, release_version, utc_build_time) (ticdc_server_build_info{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", job=~\".*ticdc.*\", instance=~\"$ticdc_instance\"}) or (max by (instance, ticdc_arch, kernel_type, git_hash, release_version, utc_build_time) (label_replace(label_replace(label_replace(label_replace(label_replace(ticdc_server_etcd_health_check_duration_count{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", job=~\".*ticdc.*\", instance=~\"$ticdc_instance\"}, \"ticdc_arch\", \"oldarch\", \"instance\", \".*\"), \"kernel_type\", \"unknown\", \"instance\", \".*\"), \"git_hash\", \"unknown\", \"instance\", \".*\"), \"release_version\", \"unknown\", \"instance\", \".*\"), \"utc_build_time\", \"unknown\", \"instance\", \".*\"))) unless on (instance) ticdc_server_build_info{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", job=~\".*ticdc.*\", instance=~\"$ticdc_instance\"})",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The new PromQL query is functionally correct for providing a fallback for older TiCDC versions. However, its length and the deeply nested label_replace calls make it difficult to read and maintain.

For improved readability, you could consider using a recording rule in Prometheus to pre-calculate the fallback metric with the necessary labels. This would simplify the dashboard query significantly.

If a recording rule is not feasible, adding comments within the Grafana panel's description explaining the query logic would be helpful for future maintenance.

"format": "time_series",
"instant": true,
"refId": "A"
Expand All @@ -3562,11 +3562,12 @@
"__name__": true
},
"indexByName": {
"git_hash": 2,
"git_hash": 3,
"instance": 0,
"kernel_type": 1,
"release_version": 3,
"utc_build_time": 4
"kernel_type": 2,
"release_version": 4,
"ticdc_arch": 1,
"utc_build_time": 5
},
"renameByName": {}
}
Expand Down Expand Up @@ -25515,4 +25516,4 @@
"title": "${DS_TEST-CLUSTER}-TiCDC-New-Arch",
"uid": "YiGL8hBZ0aac",
"version": 38
}
}
13 changes: 7 additions & 6 deletions metrics/nextgengrafana/ticdc_new_arch_next_gen.json
Original file line number Diff line number Diff line change
Expand Up @@ -3540,7 +3540,7 @@
"pluginVersion": "7.5.17",
"targets": [
{
"expr": "max by (instance, kernel_type, git_hash, release_version, utc_build_time) (ticdc_server_build_info{k8s_cluster=\"$k8s_cluster\", sharedpool_id=\"$tidb_cluster\", job=~\".*ticdc.*\", instance=~\"$ticdc_instance\"})",
"expr": "max by (instance, ticdc_arch, kernel_type, git_hash, release_version, utc_build_time) (ticdc_server_build_info{k8s_cluster=\"$k8s_cluster\", sharedpool_id=\"$tidb_cluster\", job=~\".*ticdc.*\", instance=~\"$ticdc_instance\"}) or (max by (instance, ticdc_arch, kernel_type, git_hash, release_version, utc_build_time) (label_replace(label_replace(label_replace(label_replace(label_replace(ticdc_server_etcd_health_check_duration_count{k8s_cluster=\"$k8s_cluster\", sharedpool_id=\"$tidb_cluster\", job=~\".*ticdc.*\", instance=~\"$ticdc_instance\"}, \"ticdc_arch\", \"oldarch\", \"instance\", \".*\"), \"kernel_type\", \"unknown\", \"instance\", \".*\"), \"git_hash\", \"unknown\", \"instance\", \".*\"), \"release_version\", \"unknown\", \"instance\", \".*\"), \"utc_build_time\", \"unknown\", \"instance\", \".*\"))) unless on (instance) ticdc_server_build_info{k8s_cluster=\"$k8s_cluster\", sharedpool_id=\"$tidb_cluster\", job=~\".*ticdc.*\", instance=~\"$ticdc_instance\"})",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the other dashboard file, this PromQL query is very long and complex due to the nested label_replace functions for fallback support. This impacts readability and maintainability.

Consider using a Prometheus recording rule to abstract away this complexity. A recording rule could generate a clean metric for old-architecture nodes, which would make this dashboard query much simpler.

If that's not an option, at least a comment in the panel description explaining the query would be beneficial.

"format": "time_series",
"instant": true,
"refId": "A"
Expand All @@ -3562,11 +3562,12 @@
"__name__": true
},
"indexByName": {
"git_hash": 2,
"git_hash": 3,
"instance": 0,
"kernel_type": 1,
"release_version": 3,
"utc_build_time": 4
"kernel_type": 2,
"release_version": 4,
"ticdc_arch": 1,
"utc_build_time": 5
},
"renameByName": {}
}
Expand Down Expand Up @@ -25515,4 +25516,4 @@
"title": "${DS_TEST-CLUSTER}-TiCDC-New-Arch",
"uid": "YiGL8hBZ0aac",
"version": 38
}
}
7 changes: 4 additions & 3 deletions pkg/metrics/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ var (
Help: "The value of GOMAXPROCS",
})

// buildInfo is a metric with a constant '1' value, labeled by the build metadata.
// It is used by dashboards to identify the exact binary running on each TiCDC server.
// BuildInfo is a metric with a constant '1' value, labeled by the build metadata.
// It is used by dashboards to identify the exact binary running on each TiCDC server,
// including whether the process is running in TiCDC's new or old architecture mode.
BuildInfo = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "ticdc",
Subsystem: "server",
Name: "build_info",
Help: "TiCDC build information as labels.",
},
[]string{"release_version", "git_hash", "utc_build_time", "kernel_type"},
[]string{"release_version", "git_hash", "utc_build_time", "kernel_type", "ticdc_arch"},
)
)

Expand Down
Loading