sonots/fluent-plugin-record-reformer

${message} support for attributes in various JSON levels

Closed this issue · 3 comments

Hi @sonots ,

Is it possible to add a small tweak in the code to pull out attribute values from various parts of the JSON. Looks like it supports pulling out the attributes only at the first level.

For example:

{
    "level_1_a": "value-of-level_1_a",
    "b": "value-of-b",
    "sub": {
        "level_2_a": "value-of-level_2_a",

        "sub_sub": {
            "level_3_a": "value-of-level_3_a"
        }
    }
}

Below does not work (giving empty values for all except for the level_1_a

<record>
    hostname ${hostname}
    all_a_values  ${record["level_1_a"]},${record["sub.level_2_a"]},${record["sub.sub_sub.level_3_a"]}
</record>

Below works

<record>
    hostname ${hostname}
    all_a_values  ${record["level_1_a"]}
</record>

Is it a JSON string or a hash record internally?

If it is a hash record, you should be able to get like

${record["message"]["sub"]["level_2_a"]}

It's a hash record. Let me try that and get back @sonots

Worked! Thanks @sonots for the quick help!