"Logstash"-process data using mutate

Source: Internet
Author: User
Tags logstash

Mutate:http://www.logstash.net/docs/1.4.2/filters/mutate


Use Logstash to extract the Ora error from the alter log of Oracle.

The log format is as follows:

ALTER DATABASE openerrors in file d:\oracle\diag\rdbms\hxw168\hxw168\trace\hxw168_ora_6148.trc:ora-01589: To open a database you must use the Resetlogs or Noresetlogs option ORA-1589 signalled During:alter database Open...alter


Logstash content:

input{file{ codec => plain {charset =>  "CP936"   #windows下的编码是cp936 ( CHCP view)}type =>  "Oracleerr" path =>  "D:/logsystem/logstash/bin/test/alert_hxw168.log"    start_position =>  "Beginning"} #stdin {type =>  "Hxwtest"}}filter{ mutate{         #以: Divide the message content and display it in data mode.          #比如abc:efg => message[0] = abc  message[1]=efg        split => ["Message", ":"]}# The content of the first data is ora-xxxxx in this format, which is the Ora error. Add two fields #oraerr oradesif [message][0] =~ /^ora-[0-9]{5}/ {mutate{add_field =>    {  "Oraerr"  =>  "%{[message][0]}"   "Orades"  =>  "%{[message" [1]} "}}}} output{      #有ORAERR字段, the output.      if [oraerr]{    &Nbsp;  stdout{codec => rubydebug}}} 


Results:

1.{        "Message"  => [         [0]  "ORA-00322",        [1]  "  log  2   (for thread  1)   not the latest copy \ r "    ],      " @version "  =>  "1",     "@timestamp"  =>  "2014-12-12t15:50:53.790z",            "type"  =>  "Oracleerr",            "Host"  =>  "Huangwen",            "path"  =>  "D:/logsystem/logstash/bin/test/alert_hxw168.log",          "Oraerr"  =>  "ORA-00322",          "Orades"  =>  "  log  2  (for thread  1)   not the latest copy \ r"}2. {        "MeSsage " => [        [0] " ORA-00312 ",         [1]  "  Online logs  2  thread  1",         [2]  "  D",        [3]  "\\ORACLE\\ Oradata\\hxw168\\redo02. LOG ' \ R '     ],       ' @version '  =>  ' 1 ',      "@timestamp"  =>  "2014-12-12t15:50:53.790z",            "type"  =>  "Oracleerr",            "Host"  =>  "Huangwen",           " Path " => " D:/logsystem/logstash/bin/test/alert_hxw168.log ",          "Oraerr"  =>  "ORA-00312",         "Orades"  =>  "   Online logs  2  thread  1 "}


This article from "Despite the wrong, let me wrong to die!" "Blog, be sure to keep this provenance http://hxw168.blog.51cto.com/8718136/1589498

"Logstash"-process data using mutate

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.