conf.set(FlumeConfiguration.COLLECTOR_OUTPUT_FORMAT, "avrojson");
// build a sink that outputs to that format.
File f = FileUtil.mktempdir();
SinkBuilder builder = EscapedCustomDfsSink.builder();
EventSink snk = builder.build(new Context(), "file:///" + f.getPath()
+ "/sub-%{service}");
Event e = new EventImpl("this is a test message".getBytes());
Attributes.setString(e, "service", "foo");
snk.open();
snk.append(e);
snk.close();
ByteArrayOutputStream exWriter = new ByteArrayOutputStream();
AvroJsonOutputFormat ajof = new AvroJsonOutputFormat();
ajof.format(exWriter, e);
exWriter.close();