2016-04-15 16:45:21 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
ELASTICSEARCH=http://localhost:9200
|
|
|
|
else
|
|
|
|
ELASTICSEARCH=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$2" ]; then
|
|
|
|
CURL=curl
|
|
|
|
else
|
|
|
|
CURL="curl --user $2"
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo $CURL
|
|
|
|
DIR=dashboards
|
|
|
|
|
|
|
|
for file in $DIR/search/*.json
|
|
|
|
do
|
|
|
|
name=`basename $file .json`
|
|
|
|
echo "Loading search $name:"
|
|
|
|
$CURL -XPUT $ELASTICSEARCH/.kibana/search/$name \
|
|
|
|
-d @$file || exit 1
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
|
|
|
|
for file in $DIR/visualization/*.json
|
|
|
|
do
|
|
|
|
name=`basename $file .json`
|
|
|
|
echo "Loading visualization $name:"
|
|
|
|
$CURL -XPUT $ELASTICSEARCH/.kibana/visualization/$name \
|
|
|
|
-d @$file || exit 1
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
|
|
|
|
for file in $DIR/dashboard/*.json
|
|
|
|
do
|
|
|
|
name=`basename $file .json`
|
|
|
|
echo "Loading dashboard $name:"
|
|
|
|
$CURL -XPUT $ELASTICSEARCH/.kibana/dashboard/$name \
|
|
|
|
-d @$file || exit 1
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
|
|
|
|
for file in $DIR/index-pattern/*.json
|
|
|
|
do
|
|
|
|
name=`basename $file .json`
|
|
|
|
printf -v escape "%q" $name
|
|
|
|
echo "Loading index pattern $escape:"
|
|
|
|
|
|
|
|
$CURL -XPUT $ELASTICSEARCH/.kibana/index-pattern/$escape \
|
|
|
|
-d @$file || exit 1
|
|
|
|
echo
|
|
|
|
done
|
|
|
|
|
|
|
|
|