Skip to content

Commit

Permalink
Port 'rename' feature from beats-dashboards (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
radoondas authored and monicasarbu committed Apr 21, 2016
1 parent 4e2223e commit 23b3b0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
5 changes: 5 additions & 0 deletions dev-tools/.beatconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
packetbeat-/packetbeat-
filebeat-/filebeat-
topbeat-/topbeat-
winlogonbeat-/winlogonbeat-
logstash-/logstash-
23 changes: 19 additions & 4 deletions dev-tools/import_dashboards.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ ELASTICSEARCH=http://localhost:9200
CURL=curl
KIBANA_INDEX=".kibana"
DIR=.
BEAT_CONFIG=".beatconfig"

print_usage() {
echo "
Import the dashboards, visualizations and index patterns into Kibana.
Import the dashboards, visualizations and index patterns into Kibana.
The Kibana dashboards together with its dependencies are saved into a
special index pattern in Elasticsearch (by default .kibana), so you need to
special index pattern in Elasticsearch (by default .kibana), so you need to
specify the Elasticsearch URL and optionally an username and password.
Usage:
Expand Down Expand Up @@ -107,14 +108,28 @@ fi

echo "Import dashboards,visualizations, searches and index pattern from ${DIR} to ${ELASTICSEARCH} in ${KIBANA_INDEX}"

if [ -f ${BEAT_CONFIG} ]; then
for ln in `cat ${BEAT_CONFIG}`; do
BUILD_STRING="${BUILD_STRING}s/${ln}/g;"
done
SED_STRING=`echo ${BUILD_STRING} | sed 's/;$//'`
fi
# Failsafe
if [ -z ${SED_STRING} ]; then
SED_STRING="s/packetbeat-/packetbeat-/g;s/filebeat-/filebeat-/g;s/topbeat-/topbeat-/g;s/winlogonbeat-/winlogonbeat-/g"
fi

TMP_SED_FILE="${DIR}/search/tmp_search.json"
for file in ${DIR}/search/*.json
do
NAME=`basename ${file} .json`
echo "Import search ${NAME}:"
sed ${SED_STRING} ${file} > ${TMP_SED_FILE}
${CURL} -XPUT ${ELASTICSEARCH}/${KIBANA_INDEX}/search/${NAME} \
-d @${file} || exit 1
-d @${TMP_SED_FILE} || exit 1
echo
done
rm ${TMP_SED_FILE}

for file in ${DIR}/visualization/*.json
do
Expand Down

0 comments on commit 23b3b0d

Please sign in to comment.