2017-09-06 6 views
0

나는 다음과 같은 로그 항목이 있습니다Logstash 문제

내가 할 노력하고있어 무엇
2017-08-29 01:10:11.111 [http-noo-111-exe-1] TRACE com.javasystemsolutions.xml.gateway.Actions - The XML Gateway encountered an error. The message was Server with id OPA is not configured. 

The template in use was TEST_Create_Incident_elkmonitoring. 

The server in use was OPA. 

The input XML was <incident> 
     <summary>Test Monitoring - Summary</summary> 
     <notes>Test Monitoring - Summary</notes> 
     <product>ELK FAQ</product> </incident> com.javasystemsolutions.xml.gateway.ServerNotFoundException: Server with id OPA is not configured 
     at com.javasystemsolutions.xml.gateway.input.PostActions.doPost(PostActions.java:215) [jss-xmlgateway.jar:?] 
     at com.javasystemsolutions.xml.gateway.input.PostActions.postAction(PostActions.java:86) [jss-xmlgateway.jar:?] 

, 정규식을 사용하고 입사 태그 사이의 텍스트를 식별하는 것입니다, 그러나 보인다 뭔가 잘못이다 내 정규 표현식은 regex101 웹 사이트에서 작동하지만 configtest는 Configuration OK를 반환합니다. 내 설정이 아래에 있습니다. 누군가가 잘못된 점을 알고 있습니까?

# The # character at the beginning of a line indicates a comment. Use 
# comments to describe your configuration. 
input { 
    file { 
     type => "logs" 
     path => "C:/logs/*.log" 
     add_field => [ "Application", "ELK_GW_Test" ] 
     add_field => [ "secret", "1234" ] 
     start_position => beginning 

     codec => multiline { 
      pattern => "(^%{TIMESTAMP_ISO8601})" 
      #negate => true 
      what => "previous" 
     } 
    } 
} 
filter { 
    #multiline { 
     #pattern => "(^%{TIMESTAMP_ISO8601})" 
     #negate => true 
     #what => "previous" 
    #} 
    #if "_grokparsefailure" in [tags] { 
     #drop { } 
    #} 
    if [host] == "host1" { 
     grok { 
      match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} %{NOTSPACE} %{LOGLEVEL:Severity} %{GREEDYDATA:log_message}"} 
     } 
     grok { 
     match => {"message" => "<incident>(?<incident>[\s\S]*)</incident>"} 
    } 
    } 
} 
output { 
    tcp { 
     host => "host1.com" 
     port => 1234 
     codec => "json_lines" 
    } 
    #if "The message was Server with id " in [log_message] { 
    #email { 
      #from => "[email protected]" 
      #subject => "Central logstash alert" 
      #to => "[email protected]" 
      #via => "smtp" 
      #body => "The incident details are: %{incident} \nLog file: %{path}" 
      #options => { 
       #starttls => "true" 
       #smtpIporHost => "email.XYZ.com" 
       #port => "587" 
       #userName => "[email protected]" 
       # email-server-mail-id 
       # password => "password" 
       #authenticationType => "LOGIN" 
      #} 
     #} 
    #} 
} 

답변

1

구성의이 부분은 잘못된 것입니다 :

grok { 
     match => ["requested_incident", "(?s)<incident>.+?</incident>"] 
    } 

대신이 시도 :

grok { 
     match => {"message" => "<incident>(?<incident>[\s\S]*)</incident>"} 
    } 

나는 메시지 필드에서 검색하는 사용자 정의 패턴을 사용했습니다. 발견 된 것은 사건이라고 불리는 분야에 들어갑니다.

+0

내 구성에 문제가없는 것 같아 도움을 주셔서 감사합니다. 알 수없는 이유로 내 인덱스에 아무 것도 분석되지 않습니다. –

+0

config의 문제는 'requested_incident'필드가 존재하지 않기 때문에 이 필드를 패턴과 일치 시키려고하면 아무 일도 일어나지 않습니다. 또한 지정한 패턴 ('(? s) . +? ')은 캡처 된 값으로 새 필드를 만들지 않습니다. 그래서 내 대답에 [맞춤 패턴] (https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html#_custom_patterns)을 사용했습니다. – baudsp

+0

logstash는 이벤트를 실행하고 처리하므로 구성이 유효하지만 의도 한대로 작동하지 않으므로 잘못되었습니다. – baudsp