2014-07-01 4 views
6

quando si utilizza logstash vedo un errore come questo:Logstash: Ricevuto un evento che ha una codifica dei caratteri diversa

Received an event that has a different character encoding than you configured. {:text=>"2014-06-22T11:49:57.832631+02:00 10.17.22.37 date=2014-06-22 time=11:49:55 device_id=LM150D9L23000422 log_id=0312318759 type=statistics pri=information session_id=\\\"s617nnE2019973-s617nnE3019973\\\" client_name=\\\"[<IP address>]\\\" dst_ip=\\\"<ip address>\\\" from=\\\"[email protected]\\\" to=\\\"[email protected]\\\" polid=\\\"0:1:1\\\" domain=\\\"machin.fr\\\" subject=\\\"\\xF0\\xCC\\xC1\\xD4\\xC9 \\xD4\\xCF\\xCC\\xD8\\xCB\\xCF \\xDA\\xC1 \\xD0\\xD2\\xCF\\xC4\\xC1\\xD6\\xC9!\\\" mailer=\\\"mta\\\" resolved=\\\"OK\\\" direction=\\\"in\\\" virus=\\\"\\\" disposition=\\\"Quarantine\\\" classifier=\\\"FortiGuard AntiSpam\\\" message_length=\\\"1024\\\"", :expected_charset=>"UTF-8", :level=>:warn} 

mia logstash.conf è:

input { 
    file{ 
      path => "/var/log/fortimail.log" 
     } 

}

filter { 
    grok { 
        # grok-parsing for logs 
     } 
} 
output { 
    elasticsearch { 
      host => "10.0.10.62" 
      embedded => true 
      cluster => "Mastertest" 
      node_name => "MasterNode" 
      protocol => "http" 
    } 
} 

Non so quale codec dovrebbe essere utilizzato per il formato corretto degli eventi ?? il problema è nel campo dell'oggetto.

risposta

2

Questo perché il set di caratteri predefinito è UTF-8 e il messaggio in arrivo contiene un carattere non in UTF-8 set

Per risolvere questo problema impostare il set di caratteri nella sezione di ingresso utilizzando il codec e il set di caratteri corretto. Per esempio

file { 
      path => "var/log/http/access_log" 
      type => apache_access_log 
      codec => plain { 
        charset => "ISO-8859-1" 
      } 
      stat_interval => 60 
} 

http://logstash.net/docs/1.3.3/codecs/plain

+1

Ma come puoi dire qual è il giusto set di caratteri? – JustAGuy

1

Se u ha ricevuto i registri da provare server esterni da utilizzare:

input { 
    udp { 
    port => yourListenPort 
    type => inputType 
    codec => plain { 
     charset => "ISO-8859-1" 
    } 
    } 
} 

ho lo stesso errore e ho usato questo, funziona!