Skip to content

Commit 6a12f31

Browse files
authored
metrics: Add next gen grafana json files (#61688)
ref #60864
1 parent 9f671d6 commit 6a12f31

16 files changed

+50300
-0
lines changed

pkg/metrics/nextgengrafana/README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## About
2+
3+
Use [jsonnet](https://github.com/google/go-jsonnet) to generate Grafana-compliant json scripts for use with TiDB.
4+
5+
Why jsonnet?
6+
7+
1. jsonnet is a DSL created by Google for json, which is good for advanced json editing work.
8+
2. Grafana provides the [jsonnet library](https://grafana.github.io/grafonnet-lib/) specifically for generating Grafana json, which makes maintaining TiDB's json scripts much easier.
9+
10+
## Usage
11+
12+
1. Modify the jsonnet files (e.g. tidb_summary.jsonnet).
13+
2. Run `generate_json.sh` to generate the json files by the jsonnet files.
14+
3. Commit the modifications.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2025 PingCAP, Inc.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
go install github.com/google/go-jsonnet/cmd/jsonnet@latest
17+
18+
# ref https://github.com/grafana/grafonnet-lib/issues/338, use the forked
19+
# repo which implements the addOverride and addTransformation funtion for
20+
# new table.
21+
# TODO: update to https://github.com/grafana/grafonnet
22+
git clone https://github.com/nolouch/grafonnet-lib.git
23+
24+
export JSONNET_PATH=grafonnet-lib
25+
jsonnet tidb_summary.jsonnet > tidb_summary.json
26+
jsonnet tidb_summary_with_keyspace_name.jsonnet > tidb_summary_with_keyspace_name.json
27+
jsonnet tidb_resource_control_with_keyspace_name.jsonnet > tidb_resource_control_with_keyspace_name.json
28+
rm -rf $JSONNET_PATH
29+

0 commit comments

Comments
 (0)