Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Delete all Kibana saved objects. This is useful if you're developing beats modules or just want to clear out some cruft. Works with 7.x API.
# From the docs:
# Types can be: visualization, dashboard, search, index-pattern, config, timelion-sheet
# You can also have a map type, which isn't in the docs linked above
export KIBANA_API_URL='http://elastic:password@'
export OBJECTS=$(curl "${KIBANA_API_URL}/api/saved_objects/_find?fields=id&type=index-pattern&type=visualization&type=dashboard&type=search&type=index-pattern&type=timelion-sheet&type=map&per_page=1000" | jq -rc '.saved_objects[] | {"type": .type, "id": .id } | @base64')
# Loops through the base64-encoded JSON objects
for item in ${OBJECTS};
TYPE=$(echo "${item}" | base64 -d | jq -r '.type')
ID=$(echo "${item}" | base64 -d | jq -r '.id')
echo "Deleting ${TYPE} with ID ${ID}"
curl -s -H 'kbn-xsrf: true' -XDELETE "${KIBANA_API_URL}/api/saved_objects/${TYPE}/${ID}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment