When you want to put kibana 4 export.json under git, you'll see that the file changes even if you did not touch searches, vizs or dashboards. The script below uses jq to keep kibana 4 objects (and object keys) in a constant order. Thus, no diffs if you left your kiaban untouched
Last active
October 16, 2017 06:24
-
-
Save jpparis-orange/e79dbfae1cba54799b1476fb4ddfed93 to your computer and use it in GitHub Desktop.
normalize kibana4 save files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
if [ -z "$1" ] | |
then | |
echo "*** Missing file argument" >&2 | |
exit 1 | |
fi | |
echo "--- Copying to '$1.sav'..." | |
cp $1 $1.sav | |
echo "--- Normalizing '$1'..." | |
cat $1.sav | sed -e 's/ "_id":/ "____id":/' | jq --indent 0 '.[]' | sort | \ | |
jq -s -S '[ .[] | | |
._source.kibanaSavedObjectMeta.searchSourceJSON |= fromjson | | |
( select(._type == "visualization") | ._source.visState |= fromjson | . ) // . | |
]' | \ | |
jq '[.[] | | |
._source.kibanaSavedObjectMeta.searchSourceJSON |= tojson | | |
( select(._type == "visualization") | ._source.visState |= tojson | . ) // . | |
]' | \ | |
sed -e 's/ "____id":/ "_id":/' > $1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment