mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Devenv: Create script to provision many folders (#75427)
* user essentials mob! 🔱 * user essentials mob! 🔱 lastFile:devenv/bulk-folders/bulk-folders.sh * user essentials mob! 🔱 lastFile:devenv/setup.sh * user essentials mob! 🔱 lastFile:devenv/setup.sh * user essentials mob! 🔱 * user essentials mob! 🔱 * user essentials mob! 🔱 * codeowners --------- Co-authored-by: eledobleefe <laura.fernandez@grafana.com> Co-authored-by: Laura Benz <laura.benz@grafana.com> Co-authored-by: Tobias Skarhed <tobias.skarhed@gmail.com>
This commit is contained in:
1
.github/CODEOWNERS
vendored
1
.github/CODEOWNERS
vendored
@@ -166,6 +166,7 @@
|
|||||||
/devenv/docker/blocks/self-instrumentation* @grafana/observability-metrics
|
/devenv/docker/blocks/self-instrumentation* @grafana/observability-metrics
|
||||||
|
|
||||||
/devenv/bulk-dashboards/ @grafana/dashboards-squad
|
/devenv/bulk-dashboards/ @grafana/dashboards-squad
|
||||||
|
/devenv/bulk-folders/ @grafana/grafana-frontend-platform
|
||||||
/devenv/bulk_alerting_dashboards/ @grafana/alerting-backend-product
|
/devenv/bulk_alerting_dashboards/ @grafana/alerting-backend-product
|
||||||
/devenv/create_docker_compose.sh @grafana/backend-platform
|
/devenv/create_docker_compose.sh @grafana/backend-platform
|
||||||
/devenv/dashboards.yaml @grafana/dashboards-squad
|
/devenv/dashboards.yaml @grafana/dashboards-squad
|
||||||
|
|||||||
7
.gitignore
vendored
7
.gitignore
vendored
@@ -87,8 +87,10 @@ public/css/*.min.css
|
|||||||
/devenv/docker/ha-test-unified-alerting/logs/webhook/webhook-listener.log
|
/devenv/docker/ha-test-unified-alerting/logs/webhook/webhook-listener.log
|
||||||
|
|
||||||
conf/custom.ini
|
conf/custom.ini
|
||||||
/conf/provisioning/**/custom.yaml
|
|
||||||
/conf/provisioning/**/dev.yaml
|
/conf/provisioning/**/*.yaml
|
||||||
|
!/conf/provisioning/**/sample.yaml
|
||||||
|
|
||||||
/conf/ldap_dev.toml
|
/conf/ldap_dev.toml
|
||||||
/conf/ldap_freeipa.toml
|
/conf/ldap_freeipa.toml
|
||||||
profile.cov
|
profile.cov
|
||||||
@@ -126,6 +128,7 @@ pkg/services/quota/quotaimpl/storage/storage.json
|
|||||||
*.orig
|
*.orig
|
||||||
|
|
||||||
/devenv/bulk-dashboards/*.json
|
/devenv/bulk-dashboards/*.json
|
||||||
|
/devenv/bulk-folders/*/*.json
|
||||||
/devenv/bulk_alerting_dashboards/*.json
|
/devenv/bulk_alerting_dashboards/*.json
|
||||||
/devenv/datasources_bulk.yaml
|
/devenv/datasources_bulk.yaml
|
||||||
/devenv/bulk_alerting_dashboards/bulk_alerting_datasources.yaml
|
/devenv/bulk_alerting_dashboards/bulk_alerting_datasources.yaml
|
||||||
|
|||||||
17
devenv/bulk-folders/bulk-folders.sh
Executable file
17
devenv/bulk-folders/bulk-folders.sh
Executable file
@@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
numberOfFolders=${1:-200}
|
||||||
|
numberOfDashboardsPerFolder=${2:-3}
|
||||||
|
|
||||||
|
for (( folderCounter=1; folderCounter<="$numberOfFolders"; folderCounter++ ))
|
||||||
|
do
|
||||||
|
echo "Creating folder $folderCounter"
|
||||||
|
folderPath="bulk-folders/Bulk Folder ${folderCounter}"
|
||||||
|
|
||||||
|
mkdir -p "$folderPath"
|
||||||
|
|
||||||
|
for (( dashCounter=1; dashCounter<="$numberOfDashboardsPerFolder"; dashCounter++ ))
|
||||||
|
do
|
||||||
|
jsonnet -o "$folderPath/dashboard${dashCounter}.json" -e "local bulkDash = import 'bulk-dashboards/bulkdash.jsonnet'; bulkDash + { uid: 'bulk-folder-${folderCounter}-${dashCounter}', title: 'Bulk Folder ${folderCounter} Dashboard ${dashCounter}' }"
|
||||||
|
done
|
||||||
|
done
|
||||||
8
devenv/bulk-folders/bulk-folders.yaml
Normal file
8
devenv/bulk-folders/bulk-folders.yaml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: 1
|
||||||
|
|
||||||
|
providers:
|
||||||
|
- name: 'Bulk folders'
|
||||||
|
type: file
|
||||||
|
options:
|
||||||
|
foldersFromFilesStructure: true
|
||||||
|
path: devenv/bulk-folders
|
||||||
@@ -35,6 +35,11 @@ bulkAlertingDashboard() {
|
|||||||
ln -s -f ../../../devenv/bulk_alerting_dashboards/bulk_alerting_datasources.yaml ../conf/provisioning/datasources/custom.yaml
|
ln -s -f ../../../devenv/bulk_alerting_dashboards/bulk_alerting_datasources.yaml ../conf/provisioning/datasources/custom.yaml
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bulkFolders() {
|
||||||
|
./bulk-folders/bulk-folders.sh "$1"
|
||||||
|
ln -s -f ../../../devenv/bulk-folders/bulk-folders.yaml ../conf/provisioning/dashboards/bulk-folders.yaml
|
||||||
|
}
|
||||||
|
|
||||||
requiresJsonnet() {
|
requiresJsonnet() {
|
||||||
if ! type "jsonnet" > /dev/null; then
|
if ! type "jsonnet" > /dev/null; then
|
||||||
echo "you need you install jsonnet to run this script"
|
echo "you need you install jsonnet to run this script"
|
||||||
@@ -57,23 +62,28 @@ devDatasources() {
|
|||||||
usage() {
|
usage() {
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo " bulk-dashboards - create and provisioning 400 dashboards"
|
echo " bulk-dashboards - provision 400 dashboards"
|
||||||
echo " bulk-alerting-dashboards - create and provisioning 400 dashboards with alerts"
|
echo " bulk-alerting-dashboards - provision 400 dashboards with alerts"
|
||||||
echo " no args - provisioning core datasources and dev dashboards"
|
echo " bulk-folders [folders] [dashboards] - provision many folders with dashboards"
|
||||||
|
echo " bulk-folders - provision 200 folders with 3 dashboards in each"
|
||||||
|
echo " no args - provision core datasources and dev dashboards"
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
echo -e "------------------------------------------------------------------"
|
echo -e "----------------------------------------------------------------------------"
|
||||||
echo -e "This script sets up provisioning for dev datasources and dashboards"
|
echo -e "This script sets up provisioning for dev datasources, dashboards and folders"
|
||||||
echo -e "------------------------------------------------------------------"
|
echo -e "----------------------------------------------------------------------------"
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
|
|
||||||
local cmd=$1
|
local cmd=$1
|
||||||
|
local arg1=$2
|
||||||
|
|
||||||
if [[ $cmd == "bulk-alerting-dashboards" ]]; then
|
if [[ $cmd == "bulk-alerting-dashboards" ]]; then
|
||||||
bulkAlertingDashboard
|
bulkAlertingDashboard
|
||||||
elif [[ $cmd == "bulk-dashboards" ]]; then
|
elif [[ $cmd == "bulk-dashboards" ]]; then
|
||||||
bulkDashboard
|
bulkDashboard
|
||||||
|
elif [[ $cmd == "bulk-folders" ]]; then
|
||||||
|
bulkFolders "$arg1"
|
||||||
else
|
else
|
||||||
devDashboards
|
devDashboards
|
||||||
devDatasources
|
devDatasources
|
||||||
|
|||||||
Reference in New Issue
Block a user