2016-06-29 5 views
0

logstash conf 필터에서 변수 (variable name = targetmailid) 및 출력 필드에 여러 이메일 아이디를 지정했는데 해당 변수를 사용하려고합니다. 그러나 여러 개의 전자 메일 ID를 출력 할 때 참조 용으로 사용해야합니다. 제발 제안 해주세요.복수 수신자에게 logstash 메일

filter { 
     kv { 
       field_split => "," 
       value_split=>":" 

     } 

     if [ref_type] =~ /tag/ { 
       ruby { 

        code => "tag= event['ref'] 

           targetmailid = '[email protected],[email protected],[email protected]' 

           } 
        } 
     } 


     output { 

     if "tagcreate" in [tags] { 
       email { 
         body => "test messgage" 
         from => "[email protected]" 
         to => "[email protected]" 
         cc => "targetmailid" 
         subject => "test mail" 
         options => { 
          smtpIporHost => "smtp" 
          port => 25 
            } 
           } 
         } 

답변

1

당신은이 같은 sprintf와 형식 %{...}를 사용해야합니다 :

email { 
    body => "test messgage" 
    from => "[email protected]" 
    to => "[email protected]" 
    cc => "%{targetmailid}"   <--- modify this 
    subject => "test mail" 
    options => { 
     smtpIporHost => "smtp" 
     port => 25 
    } 
} 

UPDATE 또한

다음과 같은 부분을 수정해야합니다

if [ref_type] =~ /tag/ { 
     ruby { 
      code => "event['targetmailid'] = '[email protected],[email protected],[email protected]'" 
     } 
    } else { 
     mutate { 
      add_field => { "targetmailid" => ""} 
     } 
    } 
+0

안녕하세요, I 위와 같이 수정 한 후이 오류가 발생하여 로그를 다시 시작했습니다. 은신처 conf. Net :: SMTPSyntaxError : 501 # 5.1.3 사용자 이름에 잘못된 문자 ('%')가 있습니다. 감사합니다. – bsd

+0

즉, 모든 이벤트에서 'targetmailid'변수를 사용할 수 없습니다. 'targetmailid' 필드를 생성하는 곳에서'else'를 추가해야합니다 ('ruby' 필터는'code => '... "매개 변수가 빠져 있음에주의하십시오).' ref_type'이 '/ tag /'와 일치하지 않습니다. – Val

+0

안녕하세요, 저는 원래 질문을 편집했습니다. 나는 code => 아래에만 targetmailid = 'testuser1 @ mail.com, testuser2 @ mail.com, testuser3 @ mail.com'을 추가했습니다. 감사. – bsd

관련 문제