Custom log processing/parsing - linux

I have such log format:
[26830431.7966868][4][0.013590574264526367][30398][api][1374829886.320353][init]
GET /foo
{"controller"=>"foo", "action"=>"index"}
[26830431.7966868][666][2.1876697540283203][30398][api][1374829888.4944339][request_end]
200 OK
The entry is constracted using such pattern:
[request_id][user_id][time_from_request_started][process_id][app][timestamp][tagline]
payload
Durring request I have many point where I log something - app basically has complex behaviour. This helps me debug a lot the user behaviour.
The way I would like to parse it is that I would like to make have directory structure like this:
req_id
|
|----[time_from_request_started][process_id][timestamp][tagline]
|
etc
Basically each directory will have name based on req_id, with files wchich names are rest of tagline. These files will include payload.
And also I will have other directory, with users ids, which will contain symlinks to request done by this user.
First question: Is this structure correct? In my opinion it will make easy fast log access. The reason I want to use directories and files is that I like unix approach, and try it (feel by myself its drawbacks and advantages)
Second question: I will have no problem to use ruby for creating this. But I would like to learn some new tool, which is better suited for this. I am thinking about using just unix tools (pipe, awk etc) to achieve this, or write parser in golang which I am learning right now (even have time to implement simple map reduce). What tool is best suited for this?

I would not store logs in a directory to see how the users behave.
Depending on what behaviour you want to keep track of you could use different tools. One of these could be mixpanel or keen.io.
Instead of logging what the user did in a log file you would sent an event to either of those (they are pretty similar, pick the one you think has better docs / lib), then you would graph those events to better understand the behaviour of your users. I've done this a lot recently, to display data in a nice way I've used rickshaw.
The key point why I'm suggesting this is that if you go the file route you will still have to find a way to understand your data, something that graphs will help you a lot at. Also, visualization is something keen.io does by default, you may still want to do your graphs but it's a good start.
Hope this helped.

Is this structure correct?
Only you can know that, it depends directly on how the data needs be accessed and used.
What tool is best suited for this?
You could probably use UNIX tools to achieve this but it may as well be a good exercise to practice your Go skills by writing this. It would also be more extensible.

Related

Server-side node.js templating and merging for text files

I am trying to see if there is a library that will allow me to do merging of a JSON object with a template (txt file) on the server side. Ideally, I would like it to be able to handle some conditional statements (e.g. if, greater than, equals etc.) and looping (e.g. for).
I know there are binding libraries (e.g. angularjs), and one option might be to hack it to extract the code required to do this. Alternatively, I could create my own solution, but would rather not re-invent the wheel.
I am new to Nodejs, so I'm thinking this seems like a problem that might have been solved already.
Any ideas?
All good.
Ended up going with doT.js. Great library for what I'm doing.

Set Drupal user as 'leader' of other users

I am looking for a solution outside of Organic Groups (I think it's too heavy for this purpose).
I suspect this will require a programmatic solution so I am open to any suggestions
Without using Organic Groups, I think you would have to either write a custom module that does exactly what you want, or you could try to "piece it all together" with other contributed modules such as Rules, CCK, etc.
You could try to use nodereference to link the employees/managers together from their profile (if using content profile), but then to handle permissions for those managers I think you would need a custom module anyway. I have a feeling that you will have to write your own module as piecing something together like that would be a real mess, not flexible, and more trouble than it's worth in the end.

Using XText to create a DSL for describing proprietary XML-formats

At the moment, I have to work with XACML. As there doesn't seem to be an editor to fit my needs, and as writing documents in it is a real pain, I wonder if I could not create some sort of DSL to make creating documents easier (are less error-prone). Is this possible with XText? I have a feeling it's possible but quite hard to do (especially for someone who doesn't know XText ;-)).
Getting rid of manually edited XML files is a typical use case for Xtext. The tedious part is the syntax definition itself. As soon as you have an idea how your files should look like, it's usually straight forward to get a working prototype with Xtext. What sort of concerns do you have?

Are there any GTD apps that sync with any of the common bug tracking apps?

I'm trying to decide on a GTD app. Does anyone know of one that automatically syncs with Trac or, better yet, FogBugz?
My suspicion is that none does. Which leaves me with writing a script that does it for me.
Things stores its data in XML, but the contents of the tags are all binary, which makes writing a script nigh impossible.
OmniFocus stores its data in XML, and the contents are literal text. Plugin or script is possible.
The Hit List stores its data in a sqlite3 database. Possibly easier than XML, but I'm not sure yet. The downside is that THL doesn't support recurring tasks, which makes it less useful as a GTD app.
Has anyone tried this? Have I missed an obvious app?
ThinkingRock - Java application, XML data format with plain text, supports recurring tasks. No automatic integration built yet that I know of, but another possible option to script for.
Tomboy has some level of Bugzilla integration but nothing complex. Alternatively it would be fairly trivial to sync something plaintext based such as Vimoutliner (IMO: possibly the best GTD application ever) or Taskpaper.
Probably in terms of easiness it would go:
plaintext > XML > Database > Binary format X
You could just use wget and/or a simple perl script to download the tasks then run a few regular expressions to get it formatted correctly e.g.
<li> ... </li> -> [ ] ...
or in code:
s!<li>(.*)</li>![ ] $1!g
Why not use the task features of the bug tracking systems you're looking at as your GTD tool? Also have you looked at (task coach)[http://en.wikipedia.org/wiki/Task_Coach] It stores all its info in XML.

How to create metadata for jpeg images in xp

I have an archive of Dilbert cartoons, and would like to organize them in a way, that I can find the one I need based on something on the order of a keyword search.
I am looking for suggestions on a reasonable way to accomplish that programatically. I am leaning towards perl for an implemenation.
Personally, being a fan of Perl, I would use Image::Metadata::JPEG. There are plenty of libraries for doing this type of thing, however.
If you're looking for a program to do it, I know photoshop can, and I'm sure there are other editors (The Gimp) that can as well.
I'm not sure if you're looking for a solution for searching through the images as well, but there are numerous photo archiving programs that will allow you to tag and search within them. Picassa comes to mind.

Resources