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

发布于 2025-01-17 10:22:03 字数 424 浏览 3 评论 0原文

请帮我。

我想要的是知道如何在LogStash Elasticsearch输入期间动态更改索引。

我希望这个

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

结果

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

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

例如)使用Linux脚本

预先感谢您的帮助。

Please help me.

What I want is to know how to dynamically change the index during logstash elasticsearch input.

i want this

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

result

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

I need to be able to set the value to change every day.

ex) Using Linux scripts

Thank you in advance for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

太阳哥哥 2025-01-24 10:22:03

您可以利用环境变量

您的输入配置看起来像这样:

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

然后在运行LogStash之前从外壳设置这些变量

export YEAR=2022
export SEQ=52

./bin/logstash -f test.conf

You can leverage environment variables.

Your input configuration would look like this:

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

And then set those variables from your shell just before running Logstash

export YEAR=2022
export SEQ=52

./bin/logstash -f test.conf
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文