5/31/2018: Added support for ES6+ strict content types. (Ref: https://www.elastic.co/blog/strict-content-type-checking-for-elasticsearch-rest-requests)
Import CloudFront logs into a local Elasticsearch instance and visualize them using Kibana
export ES_ROOT=~/elasticsearch
export ES_PORT=9201
export ES_VERSION=6.0.0-rc1
\rm -rf $ES_ROOT
mkdir -p $ES_ROOT
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-$ES_VERSION.tar.gz -O $ES_ROOT/elasticsearch.tar.gz
tar xzf $ES_ROOT/elasticsearch.tar.gz -C $ES_ROOT
mv $ES_ROOT/elasticsearch-$ES_VERSION $ES_ROOT/elasticsearch
$ES_ROOT/elasticsearch/bin/elasticsearch -E http.port=$ES_PORT
curl http://$HOST:$ES_PORT
python import_logs.py --log_file_pattern 'logs/*' --es_url 'http://$HOST:$ES_PORT' --index cloudfront --type prod --clean_index --verbosity INFO
export ESKB_PORT=9211
export ESKB_UNAME=darwin # darwin | linux
export ESKB_VERSION=$ES_VERSION
wget https://artifacts.elastic.co/downloads/kibana/kibana-$ESKB_VERSION-$ESKB_UNAME-x86_64.tar.gz -O $ES_ROOT/kibana.tar.gz
tar xzf $ES_ROOT/kibana.tar.gz -C $ES_ROOT
mv $ES_ROOT/kibana-$ESKB_VERSION-$ESKB_UNAME-x86_64 $ES_ROOT/kibana
$ES_ROOT/kibana/bin/kibana --host=$HOST --port=$ESKB_PORT --elasticsearch=http://$HOST:$ES_PORT
The source code is available here under MIT licence. Feel free to use any part of the code. Please send any bugs, feedback, complaints, patches to me at varunkumar[dot]n[at]gmail[dot]com.
-- Varun