From c0cbc654988a7d6d9af00029eb760da40884ce8e Mon Sep 17 00:00:00 2001 From: Rado Ondas Date: Thu, 21 Apr 2016 08:45:40 +0200 Subject: [PATCH] Port 'rename' feature from beats-dashboards --- dev-tools/.beatconfig | 5 +++++ dev-tools/import_dashboards.sh | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 dev-tools/.beatconfig diff --git a/dev-tools/.beatconfig b/dev-tools/.beatconfig new file mode 100644 index 00000000000..965814d99e7 --- /dev/null +++ b/dev-tools/.beatconfig @@ -0,0 +1,5 @@ +packetbeat-/packetbeat- +filebeat-/filebeat- +topbeat-/topbeat- +winlogonbeat-/winlogonbeat- +logstash-/logstash- \ No newline at end of file diff --git a/dev-tools/import_dashboards.sh b/dev-tools/import_dashboards.sh index d575b2d5790..e9f75cbe889 100755 --- a/dev-tools/import_dashboards.sh +++ b/dev-tools/import_dashboards.sh @@ -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: @@ -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