简体   繁体   English

我应该如何使用Logstash操作嵌套的json输入

[英]How should I manipulate a nested json input using logstash

I want to use logstash for creating an output json from my nested input json. 我想使用logstash从嵌套的输入json创建输出json。

Assuming my input json looks something like: 假设我的输入json看起来像:

{
    "firstnestedprop": {
        "secondnestedprop": {
            "thirdnestedprop": {
                "key": "value",
                "key2": "value2"
            }
        }
    }
}

I would like to output something like: 我想输出类似:

{
    "key": "value",
    "key2": "value2"
}

Or something like: 或类似的东西:

{
    "keys": ["key", "key2"],
    "values": ["value", "value2"]
}

What plugin should I use? 我应该使用什么插件?

Can anyone provide a short example or reference me to some relevant documentation? 谁能提供一个简短的例子或参考我一些相关文档?

I managed to work it out using the ruby filter plugin , since my case was a bit more complicated than the example I've posted (included nested arrays and complex objects). 我设法使用ruby过滤器插件解决了这个问题 ,因为我的案例比我发布的示例要复杂一些(包括嵌套数组和复杂对象)。 I'm not sure if there's a better way or not, but I have tried most of the filters and the ruby filter plugin was the only one that I felt good with (the others involved regular expressions and other ugly things). 我不确定是否有更好的方法,但是我尝试了大多数过滤器,而ruby过滤器插件是我唯一感觉良好的(其他涉及正则表达式和其他难看的东西)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM