添加 'ELK/删除索引.md'
This commit is contained in:
parent
0be991f285
commit
db1e1b9206
1 changed files with 20 additions and 0 deletions
20
ELK/删除索引.md
Normal file
20
ELK/删除索引.md
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
```bash
|
||||||
|
#!/bin/bash
|
||||||
|
#http://esurl/
|
||||||
|
|
||||||
|
weekago=`date -d '7 days ago' +%Y.%m.%d`
|
||||||
|
es="http://esurl"
|
||||||
|
# 原理就是先执行 _cat/indices 列出所有的索引,然后循环结果,一个一个删除
|
||||||
|
#indices=`curl -XGET "$es/_cat/indices" | awk '{print $3}'`
|
||||||
|
indices=`curl -s -XGET "$es/_cat/indices" | awk '{print $3}'`
|
||||||
|
|
||||||
|
for i in $indices;do
|
||||||
|
if [[ $i =~ $weekago ]];then
|
||||||
|
curl -XDELETE "$es/$i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
```
|
||||||
|
kibana删除索引
|
||||||
|
```
|
||||||
|
DELETE /index-2022.11.*
|
||||||
|
```
|
Loading…
Add table
Add a link
Reference in a new issue