#!/bin/bash

dst="./tidb-dashboards/op-nextgen"
tmp="./tmp"
mkdir -p $dst
mkdir tmp

git clone --depth 1 -b master https://github.com/pingcap/tidb.git $tmp/tidb
cp $tmp/tidb/pkg/metrics/grafana/*.json $dst/
cp $tmp/tidb/metrics/grafana/*.json $dst/
cp $tmp/tidb/br/metrics/grafana/*.json $dst/

git clone --depth 1 -b master https://github.com/tikv/pd.git $tmp/pd
cp $tmp/pd/metrics/grafana/*.json $dst/

git clone --depth 1 -b dedicated https://github.com/tidbcloud/cloud-storage-engine.git $tmp/tikv
cp $tmp/tikv/metrics/grafana/*.json $dst/

git clone --depth 1 -b master https://github.com/pingcap/tiflash.git $tmp/tiflash
cp $tmp/tiflash/metrics/grafana/*.json $dst/

git clone --depth 1 -b master https://github.com/pingcap/tidb-binlog.git $tmp/tidb-binlog
cp $tmp/tidb-binlog/metrics/grafana/*.json $dst/

git clone --depth 1 -b master https://github.com/pingcap/tiflow.git $tmp/tiflow
cp $tmp/tiflow/metrics/grafana/*.json $dst/

git clone --depth 1 -b main https://github.com/pingcap/TiProxy.git $tmp/TiProxy
cp $tmp/TiProxy/pkg/metrics/grafana/*.json $dst/

git clone --depth 1 -b master https://github.com/pingcap/monitoring.git $tmp/monitoring
cp $tmp/monitoring/platform-monitoring/ansible/grafana/*.json $dst/

git clone --depth 1 -b master https://github.com/pingcap/ticdc.git $tmp/ticdc
cp $tmp/ticdc/metrics/grafana/ticdc_new_arch_next_gen.json $dst/
cp $tmp/ticdc/metrics/grafana/ticdc_new_arch_with_keyspace_name.json $dst/

rm -rf $tmp
