gpt4 book ai didi

logstash - Logstash的日志轮换脚本以清除大于两周的日志

转载 作者:行者123 更新时间:2023-12-01 07:18:16 26 4
gpt4 key购买 nike

我试图想出最好的方法来从超过两周的日志服务器中清除日志。

对于那些不知道的人,Logstash 将其日志存储在 Elasticsearch 中。我们在我工作的地方有一个非常棒的稳定 ELK 堆栈(Elasticsearch/Logstash/Kibana)。

删除 logstash 索引的典型方法是使用 curl 命令,如下所示:

#curl --user admin -XDELETE http://localhost:9200/logstash-2015.06.06
Enter host password for user 'admin':
{"acknowledged":true}

现在我正在寻找的是一种更改logstash 索引中的日期以自动清除任何超过两周的索引的编程方式。

我正在考虑使用 bash 来完成这项工作。

我很感激任何有关如何执行此操作的示例或您可能有的建议!

谢谢

谢谢!!但是你认为你可以帮助我使用 auth 来完成这项工作吗?

这是我到目前为止尝试过的:
[root@logs:~] #curator --help | grep -i auth
--http_auth TEXT Use Basic Authentication ex: user:pass
[root@logs:~] #curator delete indices --older-than 14 --time-unit days --timestring %Y.%m.%d --regex '^logstash-' --http_auth admin:secretsauce
Error: no such option: --http_auth
[root@logs:~] #curator delete indices --older-than 14 --time-unit days --timestring %Y.%m.%d --regex '^logstash-' --http_auth admin:secretsauce
Error: no such option: --http_auth
[root@logs:~] #curator delete indices --http_auth admin:secretsauce --older-than 14 --time-unit days --timestring %Y.%m.%d --regex '^logstash-'
Error: no such option: --http_auth

最佳答案

使用 Curator 。要删除超过 14 天的索引,您可以运行以下命令:

curator delete indices --older-than 14 --time-unit days --timestring %Y.%m.%d --regex '^logstash-'

关于logstash - Logstash的日志轮换脚本以清除大于两周的日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31421143/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com