Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable to rename hardcoded index names #117

Merged
merged 1 commit into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .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-
21 changes: 17 additions & 4 deletions load.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
ELASTICSEARCH=http://localhost:9200
CURL=curl
KIBANA_INDEX=".kibana"
BEAT_CONFIG=".beatconfig"

print_usage() {
echo "

Load the dashboards, visualizations and index patterns into the given
Elasticsearch instance.

Expand Down Expand Up @@ -82,21 +83,35 @@ esac
shift 2
done

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

DIR=dashboards
echo "Loading dashboards to ${ELASTICSEARCH} in ${KIBANA_INDEX}"

# Workaround for: https://github.com/elastic/beats-dashboards/issues/94
${CURL} -XPUT "${ELASTICSEARCH}/${KIBANA_INDEX}"
${CURL} -XPUT "${ELASTICSEARCH}/${KIBANA_INDEX}/_mapping/search" -d'{"search": {"properties": {"hits": {"type": "integer"}, "version": {"type": "integer"}}}}'

TMP_SED_FILE="${DIR}/search/tmp_search.json"
for file in ${DIR}/search/*.json
do
NAME=`basename ${file} .json`
echo "Loading 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 Expand Up @@ -125,5 +140,3 @@ do
-d @${file} || exit 1
echo
done