Sono un nuovo utente nello stack ELK. Sto usando UWSGI come mio server. Ho bisogno di analizzare i miei registri uwsgi usando Grok e poi analizzarli.Logstash Filtro Grok per i registri uwsgi
Qui è il formato dei miei log: -
[pid: 7731|app: 0|req: 357299/357299] ClientIP() {26 vars in 511 bytes} [Sun Mar 1 07:47:32 2015] GET /?file_name=123&start=0&end=30&device_id=abcd&verif_id=xyzsghg => generated 28 bytes in 1 msecs (HTTP/1.0 200) 2 headers in 79 bytes (1 switches on core 0)
ho usato this link per generare il mio filtro, ma non ha parsing gran parte delle informazioni.
Il filtro generato dal link qui sopra è
%{SYSLOG5424SD} %{IP}() {26 vars in 511 bytes} %{SYSLOG5424SD} GET %{URIPATHPARAM} => generated 28 bytes in 1 msecs (HTTP%{URIPATHPARAM} 200) 2 headers in 79 bytes (1 switches on core 0)
Ecco il mio file logstash-conf.
input { stdin { } }
filter {
grok {
match => { "message" => "%{SYSLOG5424SD} %{IP}() {26 vars in 511 bytes} %{SYSLOG5424SD} GET %{URIPATHPARAM} => generated 28 bytes in 1 msecs (HTTP%{URIPATHPARAM} 200) 2 headers in 79 bytes (1 switches on core 0)" }
}
date {
match => [ "timestamp" , "dd/MMM/yyyy:HH:mm:ss Z" ]
}
}
output {
stdout { codec => rubydebug }
}
Al esecuzione logstash con questo file di configurazione, viene visualizzato un messaggio di errore che dice: -
{
"message" => "[pid: 7731|app: 0|req: 357299/357299] ClientIP() {26 vars in 511 bytes} [Sun Mar 1 07:47:32 2015] GET /?file_name=123&start=0&end=30&device_id=abcd&verif_id=xyzsghg => generated 28 bytes in 1 msecs (HTTP/1.0 200) 2 headers in 79 bytes (1 switches on core 0)",
"@version" => "1",
"@timestamp" => "2015-03-01T07:57:02.291Z",
"host" => "cube26-Inspiron-3542",
"tags" => [
[0] "_grokparsefailure"
]
}
La data è stata formattata correttamente. Come faccio a estrarre altre informazioni dai miei ceppi, come il mio query parameters(filename, start,end, deviceid etc)
e ClientIP
, Response code
ecc
Inoltre, non v'è alcun built-in UWSGI log parser che può essere utilizzato, come quello costruito per apache e syslog?
EDIT
ho scritto questo per conto mio, ma getta lo stesso errore:
%{SYSLOG5424SD} %{IP:client_ip}() {%{NUMBER:vars} vars in %{NUMBER:bytes} bytes} %{SYSLOGTIMESTAMP:date} %{WORD:method} %{URIPATHPARAM:request} => generated %{NUMBER:generated_bytes} bytes in {NUMBER:secs} msecs (HTTP/1.0 %{NUMBER:response_code}) %{NUMBER:headers} headers in %{NUMBER:header_bytes} (1 switches on core 0)
EDIT 2
sono finalmente in grado di rompere io stesso. Il filtro GROK per il registro di cui sopra sarà:
\[pid: %{NUMBER:pid}\|app: %{NUMBER:app}\|req: %{NUMBER:req_num1}/%{NUMBER:req_num2}\] %{IP:client_ip} \(\) \{%{NUMBER:vars} vars in %{NUMBER:bytes} bytes\} %{SYSLOG5424SD} %{WORD:method} /\?file_name\=%{NUMBER:file_name}\&start\=%{NUMBER:start}\&end\=%{NUMBER:end} \=\> generated %{NUMBER:generated_bytes} bytes in %{NUMBER:secs} msecs \(HTTP/1.0 %{NUMBER:response_code}\) %{NUMBER:headers} headers in %{NUMBER:header_bytes}
Ma le mie domande rimangono ancora:
c'è qualche difetto uwsgi accedere filtro grop ?? **
I' ho applicato corrispondenze diverse per parametri di query diversi. C'è qualcosa nel grok che recupera da solo i diversi parametri di query ??