Skip to content

Instantly share code, notes, and snippets.

@R4wm
Last active July 17, 2023 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save R4wm/4cef4ea7e69d3d341f838c86dba7e772 to your computer and use it in GitHub Desktop.
Save R4wm/4cef4ea7e69d3d341f838c86dba7e772 to your computer and use it in GitHub Desktop.
create indexes in elasticsearch
#!/bin/bash
today=date "+%Y.%m.%d"
soc_prefix="soc-"
bot_prefix="bot_event-"
rate_limits_prefix="rate_limits-"
rate_limiting_enforcer_prefix="rate_limiting_enforcer-"
postfix="-000001"
for i in {1..61}; do
next_date=$(date -I -d "$today -$i days")
next_date=$(echo $next_date | sed 's/-/./g')
# ISO 8601 (e.g. 2020-02-20) using -I
#date -I -d "$today -$i days"
soc=$soc_prefix$next_date$postfix
bot=$bot_prefix$next_date$postfix
rl=$rate_limits_prefix$next_date$postfix
rle=$rate_limiting_enforcer_prefix$next_date$postfix
echo "$soc"
echo "$bot"
echo "$rl"
echo "$rle"
curl -XPUT -H"content-type: application/json" localhost:9200/$soc
curl -XPUT -H"content-type: application/json" localhost:9200/$bot
curl -XPUT -H"content-type: application/json" localhost:9200/$rl
curl -XPUT -H"content-type: application/json" localhost:9200/$rle
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment