Skip to content

Instantly share code, notes, and snippets.

@neilhwatson
Last active August 29, 2015 14:16
Show Gist options
  • Select an option

  • Save neilhwatson/179a0112ab1f687cd47e to your computer and use it in GitHub Desktop.

Select an option

Save neilhwatson/179a0112ab1f687cd47e to your computer and use it in GitHub Desktop.
body common control
{
bundlesequence => { "log", "test" };
}
bundle agent log
{
vars:
"x" data => parsejson('
[
{
"foo" : "this line",
"bar" : "another line"
},
{
"foo" : "next line",
"bar" : "another next line"
}
]
');
"i" slist => getindices( "x" );
reports:
"<foo>${x[${i}][foo]}</foo> <bar>${x[${i}][bar]}</bar>"
report_to_file => "/tmp/jeffa.log";
"<foo>${x[${i}][foo]}</foo> <bar>${x[${i}][bar]}</bar>"
report_to_file => "/tmp/jeffa_two.log";
}
bundle agent test
{
commands:
"/usr/bin/tail /tmp/jeffa.log";
"/usr/bin/tail /tmp/jeffa_two.log";
}
neil@ettin ~/.cfagent/inputs $ cf-agent -Kf ./jeffa.cf
2015-02-26T14:26:51-0500 notice: /default/test/commands/'/usr/bin/tail /tmp/jeffa.log'[0]: Q: "...r/bin/tail /tmp": <foo>this line</foo> <bar>another line</bar>
Q: "...r/bin/tail /tmp": <foo>next line</foo> <bar>another next line</bar>
Q: "...r/bin/tail /tmp": <foo>this line</foo> <bar>another line</bar>
Q: "...r/bin/tail /tmp": <foo>next line</foo> <bar>another next line</bar>
Q: "...r/bin/tail /tmp": <foo>this line</foo> <bar>another line</bar>
Q: "...r/bin/tail /tmp": <foo>next line</foo> <bar>another next line</bar>
Q: "...r/bin/tail /tmp": <foo>this line</foo> <bar>another line</bar>
Q: "...r/bin/tail /tmp": <foo>next line</foo> <bar>another next line</bar>
Q: "...r/bin/tail /tmp": <foo>this line</foo> <bar>another line</bar>
Q: "...r/bin/tail /tmp": <foo>next line</foo> <bar>another next line</bar>
2015-02-26T14:26:51-0500 notice: /default/test/commands/'/usr/bin/tail /tmp/jeffa_two.log'[0]: Q: "...r/bin/tail /tmp": <foo>this line</foo> <bar>another line</bar>
Q: "...r/bin/tail /tmp": <foo>next line</foo> <bar>another next line</bar>
Q: "...r/bin/tail /tmp": <foo>this line</foo> <bar>another line</bar>
Q: "...r/bin/tail /tmp": <foo>next line</foo> <bar>another next line</bar>
@nickanderson
Copy link
Copy Markdown

Nice solution neil. Thanks for all the community support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment