diff --git a/README.md b/README.md index a6d41dd..b990529 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,20 @@ All components will be installed in `reporting` namespace of the cluster. - NOTE: before installing, `reporting-init` debezium configuration, make sure to include all tables under that db beforehand. If one wants to add another table from the same db, it might be harder later on. (TODO: develop some script that adds additional tables under the same db) ### Upload Kibana dashboards -Various Kibana dashboards are available in `dashboards` folder. Upload all of them with the following script: +Various Kibana dashboards are available in [`dashboards`](./dashboards) folder. Upload all of them with the following script: ```sh cd scripts -./load_kibana_dashboards.sh +./load_kibana_dashboards.sh ../dashboards [cluster kubeconfig file] ``` The dashboards may also be uploaded manually using Kibana UI. +### Delete Kibana Dashboards +Run the following script to delete previously uploaded dashboards from [`dashboards`](./dashboards) folder. +```sh +cd scripts +./delete_kibana_dashboards.sh ../dashboards [cluster kubeconfig file] +``` + ## Custom connectors Install your own connectors as given [here](docs/connectors.md) diff --git a/scripts/delete_kibana_dashboards.sh b/scripts/delete_kibana_dashboards.sh new file mode 100755 index 0000000..b62f056 --- /dev/null +++ b/scripts/delete_kibana_dashboards.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +if [ $# -lt 1 ] ; then + echo "Usage: ./delete_kibana_dashboards.sh [kubeconfig file]" + exit 1 +fi + +if [ $# -ge 2 ] ; then + export KUBECONFIG=$2 +fi + +KIBANA_URL=$(kubectl get cm global -o jsonpath={.data.mosip-kibana-host}) +read -p "Give Kibana Host Name (Example: \"kibana.sandbox.mosip.net\" or \"box.mosip.net/kibana\"): (default: $KIBANA_URL) " TO_REPLACE +KIBANA_URL=${TO_REPLACE:-$KIBANA_URL} +unset TO_REPLACE + +for file in ${1%/}/*.ndjson ; do + echo "Loading : $file" + IFS=$'\n' larray=($(cat $file)); + for line in "${larray[@]}"; do + type=$(echo $line | jq -r '.type') + id=$(echo $line | jq -r '.id') + if [ "$type" != "null" ]; then + echo "Deleting ${type}. id - ${id}" + curl -XDELETE -H "kbn-xsrf: true" "https://${KIBANA_URL%/}/api/saved_objects/${type}/${id}" + echo ; + fi + done +done