How to output a specific fields of JSON data in logstash

I want to know how to select and output some fields from JSON data with many fields.
For example, there is the following input JSON data.

[input]
{
    "layers1": {
      "field01": {
        "sample01": "5",
        "sample02": "abc",
        "sample03": "xxxxxxxx",
        "sample04": "name001"
      },
      "field02": {
        "sample01": "5",
        "sample02": "abc",
        "sample03": "xxxxxxxx",
        "sample04": "name002"
      }
    },
    "layers2": {
      "field01": {
        "sample01": "5",
        "sample02": "abc",
        "sample03": "xxxxxxxx",
        "sample04": "name003"
      },
      "field02": {
        "sample01": "5",
        "sample02": "abc",
        "sample03": "xxxxxxxx",
        "sample04": "name004"
      }
    }
}

I want to output only each "sample04" field in the output data.

[output]
{
    "layers1": {
      "field01": {
        "sample04": "name001"
      },
      "field02": {
        "sample04": "name002"
      }
    },
    "layers2": {
      "field01": {
        "sample04": "name003"
      },
      "field02": {
        "sample04": "name004"
      }
    }
}

How should I set it in the logstash config file?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.