First off, I'm new to logstash so I appreciate any help I can get with this problem.
I'm trying to get some information from the Oracle listener log into logstash but I'm not entirely sure how do that. Logstash reads the file just fine, and I can view the info in Kibana with no problems. But, I really just want certain parts of the information.
Below is a sample of the logfile. Lots of information but the only rows I'm really interested in are the ones that have the word 'established' in them.
Then for each of those lines I want a certain number of fields (from the highlighted example below):
DATE -> (12-OCT-2015 10:32:33)
SERVICE_NAME -> (asmdb)
PROGRAM -> (sqlplus@db1)
USER -> (oracle)
HOST -> (db1)
So basically, a grep for 'established' and then regexp the fields I want. I guess grok is the way to go but I cant really figure it out.
Mon Oct 12 10:31:09 2015
WARNING: Subscription for node down event still pending
12-OCT-2015 10:32:09 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=db1)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=LISTENER)(VERSION=186647552)) * status * 0
Mon Oct 12 10:32:32 2015 12-OCT-2015 10:32:33 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=asmdb)(CID=(PROGRAM=sqlplus@db1)(HOST=db1)(USER=oracle))) * (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=38999)) * establish * asmdb * 0
12-OCT-2015 10:32:33 * service_update * asmdb * 0
12-OCT-2015 10:32:36 * service_update * asmdb * 0
However, the order of the fields I want may shift around and some of them may also be empty, and in that case I'll miss those.
Is there a way to write the match part more generic, or do (can?) I have to write a separate line for every possible scenario?
You might be able to use the kv filter, but the enclosing parentheses might make it difficult (the trim and trimkey should be useful). Otherwise a ruby filter will definitely allow you to write a generic extractor of key/value pairs.
I tried your pattern to extract the fields but I am getting compiler error or not match (_grokfailure). Below is the sample records in oracle listener log. I am looking for all the fields in assignment.
I tried your pattern to extract the fields but I am getting compiler error or not match (_grokfailure). Below is the sample records in oracle listener log. I am looking for all the fields in assignment. I need the data after that status.
Are you referring to the different types of listener log event lines (i.e. connection requests, status, tnspings, db registration events), each with a different number of fields? I ran into the same thing and ended up using conditionals. Although my example is sourcing from the XML version of the logs the conditional statements may still apply to your issue:
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.