views:

490

answers:

2

I've been looking for quite some time for an application that fills the same role as Logparser, an awesome piece of technology, but for Unix. Does anyone know of something this? (I've looked at Splunk but its an overkill, a simple command line is all I really need)

Note: Being able to make SQL queries on random logs, is great and much more efficient than grepping and its kin (because you can apply SQL based relational logic to the filtering) and SQL is much more legible than Grep for maintenance purposes when handing off a project to other teams.

A: 

The problem with Linux is there isnt really a standard 'log' format. I'm not so sure I have ever seen a log like the ones mentioned in the example.

I think you're better off building a foundation of parsing the log(s) you're interested in based on awk and grep.

Looking at the example they show

SELECT TimeGenerated, SourceName, 
EventCategoryName, Message INTO report.txt FROM Security WHERE 
EventID = 528 AND SID LIKE '%TESTUSER%'

Could be accomplished by select statement:

cat logfile | awk '{print $(1), $(2), $(3)}'

For reference: the awk statment prints columns 1, 2, and 3 respectively.

Refinement step where clause:

./base.sh | grep '528' > report.txt

I think with a little bit of finesse and not this contrived answer, you could come up with something suitable quickly.

Nick Stinemates
Agreed this is a possible solution, however just as a note. Log parser doesn't depend on any known log format, it kind of figures it out on the fly. I've given it all sort of non-standard and custom logs and it's been pretty smart about figuring out how to break them up into columns
Robert Gould
I am pretty sure his question specifically said knows about grep and doesn't find it suitable.
SquareCog
+2  A: 

There are a couple that come to mind.

  1. yaala
  2. asql
  3. select

yaala support more log file types, and has a sql like query language.

asql only support Apache's log format, and has a simple sql query language.

select support many log formats, and has a sql query language.

Steve K