Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MOS-31409] Delete Kibana Saved Objects - 1.2.0.1 #40

Open
wants to merge 3 commits into
base: release-1.2.0.1
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions scripts/delete_kibana_dashboards.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

if [ $# -lt 1 ] ; then
echo "Usage: ./delete_kibana_dashboards.sh <dashboards folder> [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