如何使用logstash输入elasticsarch索引动态值



请帮帮我。

我想知道的是如何在logstash弹性搜索输入期间动态更改索引。

我想要这个

input {
elasticsearch {
hosts => localhost:9200
index => index-+{yyyy}-{increasing value}
}
}

结果

input {
elasticsearch {
hosts => localhost:9200
index => index-2022-52
}
}

我需要能够设置每天都要更改的值。

ex(使用Linux脚本

提前感谢您的帮助。

您可以利用环境变量。

您的输入配置如下所示:

input {
elasticsearch {
hosts => localhost:9200
index => index-${YEAR}-${SEQ}
}
}

然后在运行Logstash 之前从shell中设置这些变量

export YEAR=2022
export SEQ=52
./bin/logstash -f test.conf

最新更新