Skip to content

Instantly share code, notes, and snippets.

@nickanderson
Last active September 22, 2022 19:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickanderson/8907e1ba9ee6f1d7ca5a3720bf54532a to your computer and use it in GitHub Desktop.
Save nickanderson/8907e1ba9ee6f1d7ca5a3720bf54532a to your computer and use it in GitHub Desktop.
Example for Michael2
bundle agent __main__
{
  vars:
      # Using in-line yaml
      "my_yaml" data => parseyaml('
mykey: myvalue
domain:
  name: example.com
  subdomain: asdf
nesting:
  levelzero:
    levelone: levelone
');

    "top_level_keys" slist => getindices( my_yaml );
    "nesting_keys" slist => getindices( "my_yaml[nesting]" );
    "nesting_levelzero_keys" slist => getindices( "my_yaml[nesting][levelzero]" );


    reports:
    "$(with)" with => storejson( my_yaml );
    "top level key: $(top_level_keys)";
    "nesting key: $(nesting_keys)";
    "nesting levelzero key: $(nesting_levelzero_keys)";

}
R: {
  "domain": {
    "name": "example.com",
    "subdomain": "asdf"
  },
  "mykey": "myvalue",
  "nesting": {
    "levelzero": {
      "levelone": "levelone"
    }
  }
}
R: top level key: mykey
R: top level key: domain
R: top level key: nesting
R: nesting key: levelzero
R: nesting levelzero key: levelone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment