[syslog-ng] configuring a redis syslog-ng destination
Balazs Scheidler
bazsi at balabit.hu
Sat Nov 27 08:08:37 CET 2010
On Fri, 2010-11-26 at 13:22 -0800, Jacob Vorreuter wrote:
> I'd like to configure syslog-ng to send logs to redis via a unix
> socket. This would require implementing the redis protocol as a
> template or rewrite rule. The only trick is getting the size in bytes
> of the message being processed. Is there a macro for this or some
> other way of determining message size?
>
>
> The protocol would look like this (pretending there existed a macro,
> MSG_SIZE):
>
>
> *3 (number of arguments)
> $5 (size in bytes of argument 1)
> RPUSH (operation)
> $4 (size in bytes of argument 2)
> logs (key)
> $${MSG_SIZE} (size in bytes of argument 3)
> $MSG (value)
>
>
> or as a string:
>
>
> *3\r\n$5\r\nRPUSH\r\n$4\r\nlogs\r\n$${MSG_SIZE}\r\n$MSG\r\n
>
>
> and finally as a destination with template:
>
>
> destination d_redis { unix-stream("/tmp/redis.sock") template("*3\r\n
> $5\r\nRPUSH\r\n$4\r\nlogs\r\n$${MSG_SIZE}\r\n$MSG\r\n"); };
>
>
> Does anyone have suggestions of how to accomplish this?
>
The easiest way to do this would be a template function, which I'd be
willing to include in the basicfuncs plugin. Something like this:
$(sizeof $MSG)
perhaps
$(length $MSG)
--
Bazsi
More information about the syslog-ng
mailing list