Logstash nested hashmap to top level

Hi there,

So basically I have a very complex object (input is avro) that has nested lists, hashmaps and objects inside. Simplifying, something like this:

ObjectsA { #list of object A
A1 {
HashMap1 {
Key: ObjectB1_UUID;
Value: Object B1 { B1_UUI, B1_Field_1, ... B1_Field_N }
Field_1 = ...
A2 { ...}

and so on. The output desired, or at least the one that could help a lot to start, would be to have the nested maps (only them, not the value objects) and lists on top level, for instance:

A1.HashMap1 { };

If I split the ObjectsA list, what I have at the end is a lot of fields (this is a very complex object...) like A1.HashMap1.B1.UUID.Field_1 to A1.HashMap1.B1.UUID.Field_N, which is not what I would like to have. I also tried to apply ruby coding but with pretty similar results (and also I'm a newbie at ruby..).

Any help would be much appreciated.

Many thanks

Does this get you any closer to where you want to be?

  ruby {
    code => '
      event.set("ObjectsAFlattened", [])
      d = event.get("ObjectsA")
      d.each do |k1, v1|
        v1.each do |k2, v2|
          event.set("ObjectsAFlattened", event.get("ObjectsAFlattened").push("#{k1}-#{k2}"))

Hi @Badger

Yes it helps a lot, I can work with this.

Thank you very much!

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