Skip to content

Commit 9117110

Browse files
authored
Add generate-next-gen-grafana to check target and improve sed compatibility (#3191)
close #3047
1 parent b754b8c commit 9117110

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ check-makefiles: format-makefiles
322322
format-makefiles: $(MAKE_FILES)
323323
$(SED_IN_PLACE) -e 's/^\(\t*\) /\1\t/g' -e 's/^\(\t*\) /\1/' -- $?
324324

325-
check: check-copyright fmt tidy generate_mock go-generate check-diff-line-width check-ticdc-dashboard check-makefiles
325+
check: check-copyright fmt tidy generate_mock go-generate check-diff-line-width check-ticdc-dashboard check-makefiles generate-next-gen-grafana
326326
@git --no-pager diff --exit-code || (echo "Please add changed files!" && false)
327327

328328
clean:

metrics/grafana/ticdc_new_arch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22192,5 +22192,5 @@
2219222192
"timezone": "browser",
2219322193
"title": "Test-Cluster-TiCDC-New-Arch",
2219422194
"uid": "YiGL8hBZ0aac",
22195-
"version": 11
22195+
"version": 12
2219622196
}

metrics/grafana/ticdc_new_arch_next_gen.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8951,9 +8951,9 @@
89518951
"targets": [
89528952
{
89538953
"exemplar": true,
8954-
"expr": "sum(rate(ticdc_event_store_scan_bytes{k8s_cluster=\"$k8s_cluster\", sharedpool_id=\"$tidb_cluster\", instance=~\"$ticdc_instance\"}[1m])) by (instance)",
8954+
"expr": "sum(rate(ticdc_event_store_scan_bytes{k8s_cluster=\"$k8s_cluster\", sharedpool_id=\"$tidb_cluster\", instance=~\"$ticdc_instance\"}[1m])) by (instance, type)",
89558955
"interval": "",
8956-
"legendFormat": "{{instance}}",
8956+
"legendFormat": "{{instance}}-{{type}}",
89578957
"queryType": "randomWalk",
89588958
"refId": "A"
89598959
}

metrics/grafana/ticdc_new_arch_with_keyspace_name.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8563,5 +8563,5 @@
85638563
"timezone": "browser",
85648564
"title": "Test-Cluster-TiCDC-New-Arch-KeyspaceName",
85658565
"uid": "lGT5hED6vqTn",
8566-
"version": 11
8566+
"version": 12
85678567
}

scripts/generate-next-gen-metrics.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,19 @@ ORIGIN_FILE="metrics/grafana/ticdc_new_arch.json"
1919
NEXT_GEN_SHARED_FILE="${1:-metrics/grafana/ticdc_new_arch_next_gen.json}"
2020
NEXT_GEN_USER_FILE="${2:-metrics/grafana/ticdc_new_arch_with_keyspace_name.json}"
2121

22-
sed 's/namespace/keyspace_name/g;' $ORIGIN_FILE >"$NEXT_GEN_SHARED_FILE"
22+
# Detect the appropriate sed command
23+
SED_CMD=""
24+
if command -v gsed &>/dev/null; then
25+
SED_CMD="gsed"
26+
elif [[ $(sed --version 2>/dev/null) == *"GNU"* ]]; then
27+
SED_CMD="sed"
28+
else
29+
echo "This script requires GNU sed." >&2
30+
echo "On macOS, you can install it with 'brew install gnu-sed' and use it as 'gsed'." >&2
31+
exit 1
32+
fi
33+
34+
"$SED_CMD" 's/namespace/keyspace_name/g;' $ORIGIN_FILE >"$NEXT_GEN_SHARED_FILE"
2335

2436
if ! command -v jq &>/dev/null; then
2537
echo "Error: jq is not installed. Please install it to run this script." >&2
@@ -57,7 +69,7 @@ sed -i "s/YiGL8hBZ0aac/lGT5hED6vqTn/" "$NEXT_GEN_USER_FILE"
5769

5870
echo "Userscope dashboard created at '$NEXT_GEN_USER_FILE'"
5971

60-
sed -i 's/tidb_cluster_id/tidb_cluster/' "$NEXT_GEN_SHARED_FILE"
61-
sed -i 's/tidb_cluster/sharedpool_id/' "$NEXT_GEN_SHARED_FILE"
72+
"$SED_CMD" -i 's/tidb_cluster_id/tidb_cluster/' "$NEXT_GEN_SHARED_FILE"
73+
"$SED_CMD" -i 's/tidb_cluster/sharedpool_id/' "$NEXT_GEN_SHARED_FILE"
6274

6375
echo "Sharedscope dashboard created at '$NEXT_GEN_SHARED_FILE'"

0 commit comments

Comments
 (0)