Create an es_upload.sh script, such as the following.
Note:
If the targeted Elasticsearch server is protected by a security mechanism, add the credentials or mechanism to this script.
#!/bin/bash #set -x function upload_to_es() { local _es_server=$1 # URL of Elasticsearch local _cust_name=$2 # E.g., example_company. This will result in one or more indicies of example_companty-{date}
echo "Uploading logs to $_es_server with index pre-fix $_cust_name..."
_index_id=1 _chunks=$(ls *log | sort) for _chunk in ${_chunks[@]}; do IFS= _es_index="$_cust_name"-$(echo $_chunk | awk -FT '{print $1}') echo "" echo "Converting ${_chunk} to ${_chunk}_es ..." while read -r entry; do echo "{\"index\":{\"_index\":\"$_es_index\", \"_id\":\"$_index_id\"}}"; echo $entry ((_index_id++)) done < <(cat $_chunk | jq -c '.') > ${_chunk}_es