From db1e1b9206bb8fbe33d39072bde52cd2393ac405 Mon Sep 17 00:00:00 2001 From: iProbe Date: Mon, 27 Mar 2023 19:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20'ELK/=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=B4=A2=E5=BC=95.md'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ELK/删除索引.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ELK/删除索引.md diff --git a/ELK/删除索引.md b/ELK/删除索引.md new file mode 100644 index 0000000..38cf3a8 --- /dev/null +++ b/ELK/删除索引.md @@ -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.* +``` \ No newline at end of file