From 7acb01d1bc0af58d9319c7056bdea25f63a38822 Mon Sep 17 00:00:00 2001 From: Jeff Cantrill Date: Thu, 23 Feb 2017 13:57:50 -0500 Subject: [PATCH] add utility to make it easier to get stuff from es --- elasticsearch/Dockerfile | 1 + elasticsearch/es_util | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) create mode 100755 elasticsearch/es_util diff --git a/elasticsearch/Dockerfile b/elasticsearch/Dockerfile index 60264d31c..7b65cc11a 100644 --- a/elasticsearch/Dockerfile +++ b/elasticsearch/Dockerfile @@ -40,6 +40,7 @@ ADD index_templates/ /usr/share/elasticsearch/index_templates/ ADD install.sh ${HOME}/ RUN ${HOME}/install.sh ADD run.sh ${HOME}/ +ADD es_util /usr/local/bin WORKDIR ${HOME} USER 1000 diff --git a/elasticsearch/es_util b/elasticsearch/es_util new file mode 100755 index 000000000..750f6d0df --- /dev/null +++ b/elasticsearch/es_util @@ -0,0 +1,17 @@ +#/bin/bash -euxo pipefail + +# Utility to grab documents from the ES +# instance using the admin certs and keys + +QUERY=${QUERY:-""} +INDEX=${INDEX:-"project.*"} +SIZE=${SIZE:-10} +SORT=${SORT:-"@timestamp:desc"} + +BASE=${BASE:-https://localhost:9200} + +if [ -z "${QUERY:-}" ]; then + QUERY="$BASE/$INDEX/_search?size=$SIZE&sort=$SORT" +fi + +curl -s -k --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key $QUERY | python -mjson.tool