0
我有以下的JSON语法如何使用logstash变异或红宝石滤波
{"result": {
"entities": {
"SERVICE-CCC89FB0A922657A": "service1",
"SERVICE-D279F46CD751424F": "service2",
"SERVICE-7AB760E70FCDCA18": "service3",
},
"dataPoints": {
"SERVICE-CCC89FB0A922657A": [
[
1489734240000,
1101.0
],
[
1489734300000,
null
]
],
"SERVICE-7AB760E70FCDCA18": [
[
1489734240000,
4080800.5470588235
],
[
1489734300000,
null
]
],
"SERVICE-D279F46CD751424F": [
[
1489734240000,
26677.695652173912
],
[
1489734300000,
null
]
]
}
},
"@timestamp": "2017-03-17T07:05:37.531Z",
"data": "data",
"@version": "1"
}
我想改变下列输入它elasticsearch。
{"@timestamp": "2017-03-17T07:05:37.531Z",
"data": "data",
"@version": "1",
"data" : {
"service1",: [
[
1489734240000,
1101.0
],
[
1489734300000,
null
]
],
"service3" : [
[
1489734240000,
4080800.5470588235
],
[
1489734300000,
null
]
],
"service2": [
[
1489734240000,
26677.695652173912
],
[
1489734300000,
null
]
]
}
}
这是当前logstash conf文件的内容。
input {
http_poller {
urls => {
test => {
method => get
url => "https://xxxx.com"
headers => {
Accept => "application/json"
}
}
}
request_timeout => 60
schedule => { every => "60s" }
codec => "plain"
}
}
filter {
json{
source => "message"
remove_field => ["[result][aggregationType]","message"]
}
# translate{
# }
# mutate{
# }
# ruby{
# }
}
output {
stdout {
codec => rubydebug {
#metadata => true
}
}
elasticsearch {
hosts => ["http://192.168.0.36:9200"]
}
}
我刚刚使用elasticsearch,我不知道如何实现什么过滤器使用。 我不知道是否有可能实现mutate过滤器重命名的内容。 或者我应该用ruby过滤器实现代码吗?
实体可能会与ruby过滤器一起排列,以匹配dataPoints的SERVICE- *。 但是,很难处理Ruby代码。
我希望你能帮助我。
谢谢。
感谢您的答复这个问题。 我多次查找了logstash过滤器文档页面以找到我想要的答案,并且在Google上做了几十次搜索,但是我发现很难找到我想要的答案。 文档页面只有基本用法,所以实现我想要的功能并不容易。 –