gpt4 book ai didi

elasticsearch - 如何通过使用logstash索引json文件?

转载 作者:行者123 更新时间:2023-12-03 00:54:42 24 4
gpt4 key购买 nike

我尝试使索引如下所示的json文件。我必须写一个骗子的表情。但是我不能那样做吗?你能帮助我吗?

{"level":"Information","ClientIP":"10.201.21.188","Test":"10.210.21.188"}
{"level":"Information","ClientIP":"10.202.21.187","Test":"10.220.21.188"}
{"level":"Information","ClientIP":"10.203.21.186","Test":"10.230.21.188"}
{"level":"Information","ClientIP":"10.204.21.185","Test":"10.240.21.188"}


我的logstash.conf如下:

input {
file {
type => "json"
path => ["C:/logs/test-20170933.json"]
start_position => "beginning"
}
}
filter {
grok {
match => [ "message","%{WORD:level} I HAVE TO WRITE OTHER ELEMENTS BUT HOW????"]
}
json {
source => "message"
}
}
output {
stdout {
codec => rubydebug
}
elasticsearch {
hosts => [ "localhost:9200" ]
index => "logstash-%{+YYYY.MM.dd}"
}
}


我想我们需要鬼表情才能做到这一点。我也愿意为此寻求新的创意解决方案。

最佳答案

您不需要做任何事情,您的file输入只需要一个JSON编解码器,您就可以开始了:

input {
file {
type => "json"
path => ["C:/logs/test-20170933.json"]
start_position => "beginning"
codec => "json" <-- add this
}
}
filter {
}
output {
stdout {
codec => rubydebug
}
elasticsearch {
hosts => [ "localhost:9200" ]
index => "logstash-%{+YYYY.MM.dd}"
}
}

关于elasticsearch - 如何通过使用logstash索引json文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46241231/

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