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
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
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