
rgerhards at hq
Mar 15, 2012, 10:13 AM
Post #20 of 50
(1138 views)
Permalink
|
|
Re: next question: templates, JSON and MongoDB
[In reply to]
|
|
> -----Original Message----- > From: rsyslog-bounces [at] lists [mailto:rsyslog- > bounces [at] lists] On Behalf Of Brian Knox > Sent: Thursday, March 15, 2012 12:13 PM > To: rsyslog-users > Subject: Re: [rsyslog] next question: templates, JSON and MongoDB > > Just an amendment to be explicit: I believe we need the to > define a > hierarchical data structure that can be a mix of rsyslog properties > (%programname%), the "dynamic" properties returned from mmnormalize and > other parsing modules (%$!foo%), and strings (p:Event). That's the idea, but I would still like to physically keep the properties separate. The reason simply is performance. If they are shuffled into a single data structure, "traditional" property access would be notably slower. If I duplicate them... well, then I duplicate them (copy cost, mem cost). > We then need the ability to pass that structure to a "serializer", that > would then spit out JSON, or some other format. Yep, that's actually what I am after. Replace "other format" with "BSON" and you get the picture. That beast must be capable to take the different sets of properties and mimic - with as low runtime overhead as possible - them as being in a single structure. At that point, I admit, it may be necessary to combine and copy things. On the other hand, there are probably situations (Mongo/BSON) where it could be avoided (even if it is by the sheer fact that copying into BSON is required in any case...). > > I'm going to veer off into potentially crazy-talk territory now. If we > want the ability for an output action to spit out a serialized dump of > this > hypothetical data structure, what's the potential for having output > actions > translate to binary formats as well, say protobuf? BSON is binary. So ommongodb will probably provide a good template. That's exactly why I am so interested in doing it right there. Given the rest of today's discussion, I think we are on a good path. Of course, this needs to be proven in practice when the experimental code is ready for (ab)use :-) Rainer > > Brian > > On Thu, Mar 15, 2012 at 6:46 AM, Rainer Gerhards > <rgerhards [at] hq>wrote: > > > > > > > > -----Original Message----- > > > From: rsyslog-bounces [at] lists [mailto:rsyslog- > > > bounces [at] lists] On Behalf Of Brian Knox > > > Sent: Thursday, March 15, 2012 11:45 AM > > > To: rsyslog-users > > > Subject: Re: [rsyslog] next question: templates, JSON and MongoDB > > > > > > What immediately comes to mind for me is working with python > > > dictionaries, > > > and various serialization formats. Basically, a hierarchical data > > > structure with various serializers. How that translates into > something > > > workable within an rsyslog configuration, I'm not sure yet. > > > > > > Would we agree the basic requirements would be: > > > > > > 1. The ability to define a hierarchical key / value structure out > of > > > rsyslog properties > > > 2. The ability to define serialization modules that would output > those > > > structures > > > > I think I can agree (though I would probably use somewhat different > terms > > in > > rsyslog speak - but let's start from here on). > > > > Rainer > > > > > > > > > > > On Thu, Mar 15, 2012 at 6:39 AM, Rainer Gerhards > > > <rgerhards [at] hq>wrote: > > > > > > > > -----Original Message----- > > > > > From: rsyslog-bounces [at] lists [mailto:rsyslog- > > > > > bounces [at] lists] On Behalf Of Brian Knox > > > > > Sent: Thursday, March 15, 2012 11:21 AM > > > > > To: rsyslog-users > > > > > Subject: Re: [rsyslog] next question: templates, JSON and > MongoDB > > > > > > > > > > I think the MongoDB question ties into a larger question, of > > > external > > > > > sources that use text based protocols in general. For > instance, > > > Redis, > > > > > which does not use JSON but does use a text based protocol over > > > TCP. > > > > > > > > Well... not exactly. MongoDB is a bit special as it does not work > > > with JSON > > > > natively but JSON. So I (the output plugin) must create a BSON > > > document, > > > > even > > > > if JSON is already present. If I could just simply provide the > JSON > > > doc, > > > > there would be limited double processing. Even with pure JSON > there > > > would > > > > be > > > > duplication effort if the document as such needs to be changed > prior > > > to > > > > submitting. However, there I do not see a way around. > > > > > > > > > In my case, our primary concern when interacting with external > data > > > > > stores > > > > > is always performance over convenience. Double parsing a JSON > > > document > > > > > (first into CEE, and then from CEE into a MongoDB command) > would > > > > > definitely > > > > > be a performance hit. > > > > > > > > Yep > > > > > > > > > > > > > > Thinking about it though, I would like a solution that allows > > > > > formatting > > > > > the message independently of the specific output. For instance > - > > > in > > > > > the > > > > > past I've connected rsyslog to mongodb by passing the message > over > > > ZMQ > > > > > to a > > > > > daemon that handled the mongodb loading. > > > > > > > > That's what the template system does, and it works well. However, > the > > > > current > > > > system is not doing well at field-like mapping. In essence, it > > > generates > > > > strings (either as one large or an array of them), but it does > not > > > provide > > > > mapping information. In SQL datasources that is no problem > because we > > > > generate the actual insert command. But I think we need to have > some > > > other > > > > way for the JSON structure, maybe something along the lines of > > > explicit > > > > name/value pairs. I have to admit I have no clear idea, and to > make > > > it even > > > > harder I'd like to have a couple of ideas where at least one > would be > > > > doable > > > > without too much modification in order to go to a PoC quickly. > Maybe > > > the > > > > double-formatting is an interim solution. > > > > > > > > In any case, what would a clean solution look like? > > > > > > > > Rainer > > > > > > > > > > I'll have to think about all of this more after I have some > coffee! > > > > > > > > > > Brian > > > > > > > > > > On Thu, Mar 15, 2012 at 6:08 AM, Rainer Gerhards > > > > > <rgerhards [at] hq>wrote: > > > > > > > > > > > I'll add an option, hopefully later today. Should be fairly > > > simple ;) > > > > > > Please also think a little bit about the MongoDB interface, > which > > > is > > > > > a bit > > > > > > trickier (I don'T like the idea of formatting JSON to > immediately > > > > > parse it > > > > > > again, even though this may be a working first instance > > > solution). > > > > > > > > > > > > Thx, > > > > > > Rainer > > > > > > > > > > > > > -----Original Message----- > > > > > > > From: rsyslog-bounces [at] lists [mailto:rsyslog- > > > > > > > bounces [at] lists] On Behalf Of Brian Knox > > > > > > > Sent: Thursday, March 15, 2012 11:04 AM > > > > > > > To: rsyslog-users > > > > > > > Subject: Re: [rsyslog] next question: templates, JSON and > > > MongoDB > > > > > > > > > > > > > > I posted this on the blog as well - > > > > > > > > > > > > > > For my immediate needs, being able to JSON escape > properties as > > > a > > > > > > > property > > > > > > > option is satisfactory. I'm experimenting with templates > such > > > as: > > > > > > > > > > > > > > $template cee_enhanced,"@cee: > > > > > > > > > > > > > > > > {\"Event\":{\"p_proc\":\"%programname%\",\"p_sys\":\"%hostname%\",\"tim > > > > > > > e\":\"%timestamp:::date- > > > > > > > rfc3339%\"},\"Msg\":{\"raw_msg\":\"%rawmsg%\"}}\n" > > > > > > > 26 *.* /var/log/cee_events.log;cee_enhanced > > > > > > > > > > > > > > Which works for a lot of my messages, the escaping is the > only > > > > > issue. > > > > > > > Adding a JSON escape property option would allow me to move > > > pretty > > > > > > > quickly > > > > > > > as I prototype things. > > > > > > > > > > > > > > Longer term, having some sort of JSON call where I could > pass a > > > > > > > property > > > > > > > list would be nice... although the templates do give me the > > > > > flexibility > > > > > > > of > > > > > > > specifying nested document structures, which might get > > > trickier. > > > > > I'll > > > > > > > think > > > > > > > more about it. > > > > > > > > > > > > > > > > > > > > > On Thu, Mar 15, 2012 at 5:46 AM, Rainer Gerhards > > > > > > > <rgerhards [at] hq>wrote: > > > > > > > > > > > > > > > Hi all, > > > > > > > > > > > > > > > > another question I am facing while implementing the new > > > stuff: > > > > > > > > > > > > > > > > http://blog.gerhards.net/2012/03/json-and-rsyslog- > > > templates.html > > > > > > > > > > > > > > > > Feedback is appreciated :-) > > > > > > > > > > > > > > > > Rainer > > > > > > > > _______________________________________________ > > > > > > > > rsyslog mailing list > > > > > > > > http://lists.adiscon.net/mailman/listinfo/rsyslog > > > > > > > > http://www.rsyslog.com/professional-services/ > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > rsyslog mailing list > > > > > > > http://lists.adiscon.net/mailman/listinfo/rsyslog > > > > > > > http://www.rsyslog.com/professional-services/ > > > > > > _______________________________________________ > > > > > > rsyslog mailing list > > > > > > http://lists.adiscon.net/mailman/listinfo/rsyslog > > > > > > http://www.rsyslog.com/professional-services/ > > > > > > > > > > > _______________________________________________ > > > > > rsyslog mailing list > > > > > http://lists.adiscon.net/mailman/listinfo/rsyslog > > > > > http://www.rsyslog.com/professional-services/ > > > > _______________________________________________ > > > > rsyslog mailing list > > > > http://lists.adiscon.net/mailman/listinfo/rsyslog > > > > http://www.rsyslog.com/professional-services/ > > > > > > > _______________________________________________ > > > rsyslog mailing list > > > http://lists.adiscon.net/mailman/listinfo/rsyslog > > > http://www.rsyslog.com/professional-services/ > > _______________________________________________ > > rsyslog mailing list > > http://lists.adiscon.net/mailman/listinfo/rsyslog > > http://www.rsyslog.com/professional-services/ > > > _______________________________________________ > rsyslog mailing list > http://lists.adiscon.net/mailman/listinfo/rsyslog > http://www.rsyslog.com/professional-services/ _______________________________________________ rsyslog mailing list http://lists.adiscon.net/mailman/listinfo/rsyslog http://www.rsyslog.com/professional-services/
|