-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathload.sh
executable file
·70 lines (57 loc) · 1.33 KB
/
load.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
set -e
set -x
cd $(dirname $0)
function get_name()
{
basename "$1" .json | sed -e 's/ /%20/g'
}
if [ -z "$1" ]; then
ELASTICSEARCH=http://127.0.0.1:9200
else
ELASTICSEARCH=$1
fi
if [ -z "$2" ]; then
CURL=curl
else
CURL="curl --user $2"
fi
echo $CURL
DIR=dashboards
echo "Cleaning elasticsearch's kibana data"
$CURL -XDELETE $ELASTICSEARCH/.kibana/ ||:
for file in $DIR/index-pattern/*.json
do
name="$(get_name "$file")"
echo "Loading index pattern $name:"
$CURL -XPOST "$ELASTICSEARCH/.kibana/index-pattern/$name" \
-d "@$file" || exit 1
echo
done
for file in $DIR/search/*.json
do
name="$(get_name "$file")"
echo "Loading search $name:"
$CURL -XPUT "$ELASTICSEARCH/.kibana/search/$name" \
-d "@$file" || exit 1
echo
done
for file in $DIR/visualization/*.json
do
name="$(get_name "$file")"
echo "Loading visualization $name:"
$CURL -XPUT "$ELASTICSEARCH/.kibana/visualization/$name" \
-d "@$file" || exit 1
echo
done
for file in $DIR/dashboard/*.json
do
name="$(get_name "$file")"
echo "Loading dashboard $name:"
$CURL -XPUT "$ELASTICSEARCH/.kibana/dashboard/$name" \
-d "@$file" || exit 1
echo
done
echo "Loading config:"
$CURL -XPOST $ELASTICSEARCH/.kibana/config/4.3.1 \
-d @dashboards/config.json || exit 1