Table of Contents

Prototype: data_expand(data_container)

Return type: data

Description: Transforms a data container to expand all variable references.

This function will take a data container and expand variable references once in all keys and values.

This function can accept many types of data parameters.

Any compound (arrays or maps) data structures will be expanded recursively, so for instance data in a map inside another map will be expanded.

This function is chiefly useful if you want to read data from an external source and it can contain variable references.


  • data_container: string, in the range: .*


Prepare to run the example policy:

echo '{ "$(main.x)": "$(main.y)" }' > /tmp/expand.json


bundle agent main
      "x" string => "the expanded x";
      "y" string => "the expanded y";

      "read" data => readjson("/tmp/expand.json", inf);
      "expanded" data => data_expand(read);

      "expanded_str" string => format("%S", expanded);

      "$(this.bundle): the x and y references expanded to $(expanded_str)";


R: main: the x and y references expanded to {"the expanded x":"the expanded y"}


History: Was introduced in version 3.7.0 (2015). The collecting functions behavior was added in 3.9.

See also: readcsv(), readjson(), readyaml(), mergedata(), about collecting functions, and data documentation.