Adding CLAMP Dashboard
[clamp.git] / extra / docker / elk / tools / EsAutoQuery / autoQueryLoop.sh
1 #!/bin/bash
2
3 QUERY_FILE=${1:-query.json}
4 INDEX=${2:-logstash-*}
5 HOST_URL=${3:-http://localhost:9200}
6 URL=$HOST_URL/$INDEX/_search
7
8 function usage() {
9     echo "Usage: $0 [QUERY_FILE [INDEX [HOST_URL]]]"
10     echo
11     echo "This script automatically sends the query file to elasticsearch"
12     echo "each time it's modified."
13 }
14
15 if [ "${1}" == "--help" ];
16 then
17     usage
18     exit 0
19 fi
20
21 echo "Querying '$URL' with '$QUERY_FILE'"
22 while [ 1 ];
23 do
24     curl -XGET "$URL" -H 'Content-Type: application/json' -d"@$QUERY_FILE" | js-beautify
25     echo
26     inotifywait -e modify query.json
27 done