Use of the Logstash filter

Source: Internet
Author: User
Tags logstash

Recently in the project using Logstash do log collection and filtering, feel logstash is still very powerful.

Input {file{path = "/xxx/syslog.txt" Start_position = beginning codec = Multilin e{Patterns_dir = ["/xx/logstash-1.5.3/patterns"] pattern = "^%{message}" Nega        Te = True what = "previous"}}}filter{mutate{split = ["message", "|"] Add_field = {"tmp" = "%{[message][0]}"} Add_field + = {"Deviceproduc         T "= ="%{[message][2]} "} Add_field = {" Deviceversion "="%{[message][3]} "}            Add_field = {"Signature ID" = "%{[message][4]}"} Add_field + = {            "Name" = "%{[message][5]}"} mutate{split + = ["tmp", ":"] Add_field + =        "Tmp1" = "%{[tmp][1]}"} Add_field = {"Version" = "%{[tmp][2]}"} Remove_field = ["TMP "]} grok{patterns_dir = ["/xxx/logstash-1.5.3/patterns "] match + = {" Tmp1 "="%{type:type} " "} Remove_field = [" Tmp1 "]} kv{Include_keys = [" EventId "," msg "," End "," MRT "," Modelconfiden Ce "," severity "," Relevance "," assetcriticality "," priority "," art "," RT "," CS1 "," CS2 "," CS3 "," locality "," Cs2label "," Cs3label "," Cs4label "," Flexstring1label "," Ahost "," AGT "," AV "," Atz "," Aid "," at "," DVC "," Devicezoneid "," Devicezoneuri "," DTZ "," Eventannotationstageupdatetime "," Eventannotationmodificationtime "," Eventannotationaudittrail "," Eventannotationversion "," Eventannotationflags "," Eventannotationendtime "," Eventannotationmanagerreceipttime "," _cefver "," Ad.arcsighteventpath "]} mutate{split = [" Ad.arcsighteventpat H ",", "] Add_field = {" Arcsighteventpath "="%{[ad.arcsighteventpath][0]} "} REM        Ove_field = ["Ad.arcsighteventpath"] Remove_field = ["message"]}}output{kafka{topic_id = "Rawlog" batch_num_messages = Broker_list = "10.3.162.193:39192,10.3.162.194:39192 , 10.3.162.195:39192 "codec =" JSON "} stdout{codec = Rubydebug}

Input: Access data source

Filter : filtering the data source

Output : the

One of the most important is the processing of the filter , and our requirement now is to extract the string key-value.

1, the use of split in the mutate, can be divided by the division of the processing.

2. Use regular grok to intercept the string.

3. Use KV to extract all Key-value

Use of the Logstash filter

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.