[rsyslog] working with list templates

David Lang david at lang.hm
Tue Jan 8 00:25:10 CET 2013

On Mon, 7 Jan 2013, Brian Knox wrote:

> David - no, I have batch processing working already as part of the patch
> I'm working on.  That part was actually pretty easy using rewriting the
> plugin to properly use dequeuebatchsize, etc.
> The issue is that the way the redis protocol constructs commands means that
> I can't just put a message payload with spaces in it right into a command.
>  Additionally depending on which redis command is being run, the argument
> list is variable length.
> This is handled one of two ways in the redis C api.  The first way is using
> a sprintf like interface:
> redisCommand("HINCRBY %s %s %d", stringvar, stringvar, intvar)
> Since I don't want to limit what commands a user of the output plugin can
> use, I don't see this interface being usable for this purpose
> The second way is by passing a char ** to RedisCommandArgv with some
> information about the number of elements in the char and their lengths.
> This seems like it would fit well, if I can figure out a convenient way to
> pass what I want from the template to the output plugin.
> In this case, each member of the char ** is either a redis protocol
> keyboard or one of the arguments.
> So in that case "HINCRBY", "httpd", "pageviews", "1" could be elements in
> the char **, and when passed to RedisCommandArgv, the correct protocol
> message would get constructed to send to redis.
> As per Rainer's thought.. there may be a way I could potentially use the
> string formatting options to "escape" the command into a redis protocol
> command,which is a thought that hadn't occurred to me.  I don't know if I
> like that approach better yet than my original thoughts, but it at the
> least merits some thought.

hmm, thinking about this a bit.

Are you limited to one command per log?

I'm thinking that instead of doing this as one string with something encoded in 
the string saying where to break it, you would be better off with a JSON snippet 
along the lines of

command:<string> {param1:<string>, param2:<string>}

David Lang

More information about the rsyslog mailing list