gpt4 book ai didi

elasticsearch - 使 logstash 向不同的索引添加不同的输入

转载 作者:行者123 更新时间:2023-11-29 02:45:20 25 4
gpt4 key购买 nike

我已设置 logstash 以使用嵌入式 elastisearch。
我可以记录事件。
我的 logstash conf 看起来是这样的:
https://gist.github.com/khebbie/42d72d212cf3727a03a0

现在我想添加另一个 udp 输入并将该输入编入另一个索引。

这有可能吗?我这样做是为了让报告更容易,所以我可以在一个索引中包含系统日志事件,在另一个索引中包含业务日志事件。

最佳答案

在输出部分使用 if 条件,例如,消息类型或任何消息字段对索引的选择很重要。

input {
udp {
...
type => "foo"
}
file {
...
type => "bar"
}
}

output {
if [type] == "foo" {
elasticsearch {
...
index => "foo-index"
}
} else {
elasticsearch {
...
index => "bar-index"
}
}
}

或者,如果消息类型可以直接进入索引名称,您可以有一个输出声明:

elasticsearch {
...
index => "%{type}-index"
}

关于elasticsearch - 使 logstash 向不同的索引添加不同的输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27146032/

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