Skip to content

Instantly share code, notes, and snippets.

@guessi
Created September 25, 2018 08:58
Show Gist options
  • Select an option

  • Save guessi/662297d26bcf23f27a50528471134f11 to your computer and use it in GitHub Desktop.

Select an option

Save guessi/662297d26bcf23f27a50528471134f11 to your computer and use it in GitHub Desktop.

Revisions

  1. guessi created this gist Sep 25, 2018.
    31 changes: 31 additions & 0 deletions es-dump.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    #!/usr/bin/env bash

    # simple script for dumping elastic log from one to another

    ES_SRC_ENDPOINT="192.168.0.100:9200"
    ES_DST_ENDPOINT="192.168.0.200:9200"
    ES_INDEX_NAME="logstash-2018.09.25"

    INPUT="http://${ES_SRC_ENDPOINT}/${ES_INDEX_NAME}"
    OUTPUT="http://${ES_DST_ENDPOINT}/${ES_INDEX_NAME}"

    TIME_START="2018-09-25T06:30:00.000Z"
    TIME_END="2018-09-25T06:45:00.000Z"

    BATCH_LIMIT=10000

    SEARCH_BODY='
    {
    "query": {
    "range": {
    "@timestamp": {
    "gte": "'${TIME_START}'",
    "lt": "'${TIME_END}'"
    }
    }
    }
    }'

    docker run --rm -it taskrabbit/elasticsearch-dump \
    elasticdump --input=${INPUT} --output=${OUTPUT} --limit ${BATCH_LIMIT} \
    --searchBody "${SEARCH_BODY}"