Created
September 22, 2012 15:46
-
-
Save studio3104/3766571 to your computer and use it in GitHub Desktop.
add `hostname key` to message from fluent-agent-lite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use Data::Dumper; | |
use JSON::XS; | |
use Data::MessagePack; | |
$| = 1; | |
my $mp = Data::MessagePack->new(); | |
my $message_from = $ARGV[0]; | |
while ( my $json = <STDIN> ) { | |
my $decode = eval { decode_json($json); }; | |
next if ($@); | |
$decode->{hostname} = $message_from; | |
print $mp->pack($decode); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<source> | |
type forward | |
</source> | |
<match hoge.**> | |
type forest | |
subtype exec_filter | |
remove_prefix hoge | |
<template> | |
command /home/satoshi/perl5/perlbrew/perls/perl-5.16.1/bin/perl /etc/td-agent/scripts/add_hostname.pl ${tag} | |
in_format json | |
out_format msgpack | |
tag foo.out | |
flush_interval 1s | |
</template> | |
</match> | |
<match foo.out> | |
type file | |
path /tmp/hoge.out | |
flush_interval 1s | |
</match> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment