blob: 4929412081cd1269dd5f1163cf980270e3735a76 [file] [log] [blame]
ac25505082fd72018-03-20 12:35:48 +01001#!/bin/bash
2
3QUERY_FILE=${1:-query.json}
4INDEX=${2:-logstash-*}
5HOST_URL=${3:-http://localhost:9200}
6URL=$HOST_URL/$INDEX/_search
7
8function 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
15if [ "${1}" == "--help" ];
16then
17 usage
18 exit 0
19fi
20
21echo "Querying '$URL' with '$QUERY_FILE'"
22while [ 1 ];
23do
24 curl -XGET "$URL" -H 'Content-Type: application/json' -d"@$QUERY_FILE" | js-beautify
25 echo
26 inotifywait -e modify query.json
27done