사용자 패턴 파일에 다음 패턴을 포함하는 응용 프로그램에 logstash를 통합하려고합니다.logstash 로그 구문 분석 오류 발생 : grokparsefailure
내 logstash의 conf 파일은Path: <path>/custom_pattern -- This is custom pattern file. I include this path in conf.
Content: ACCESSLOGPARSE \[%{HTTPDATE:timestamp}\] %{IPORHOST:clientip} (?: xff=%{IPORHOST:xffIp})
:
은input {
file{
path => "/tmp/jboss-logs.log"
start_position => beginning
}
}
filter {
if [path] =~ "jboss" {
mutate { replace => { "type" => "jboss_access"}}
grok {
patterns_dir => "<dir path>"
match => { "message" => "%{ACCESSLOGPARSE}" }
}
}
date {
match => [ "timestamp", "dd/MMM/yyyy:HH:mm:ss Z" ]
}
}
output {
elasticsearch { host => localhost }
stdout { codec => rubydebug }
}
은 내 보스 - logs.log 파일의 콘텐츠는 : 나는 logstash을 실행하면, 내가 출력을 다음있어
[09/Jan/2015:00:00:02 +0000] 127.0.0.1 xff=-
[09/Jan/2015:00:10:17 +0000] 100.20.10.11 xff=100.40.11.3
로그 구문 분석되지 않은 경우 .
{
"message" => "[09/Jan/2015:00:00:02 +0000] 127.0.0.1 xff=-",
"@version" => "1",
"@timestamp" => "2015-01-20T15:30:10.865Z",
"host" => "Salvador",
"path" => "/tmp/jboss-logs.log",
"type" => "jboss_access",
"tags" => [
[0] "_grokparsefailure"
]
}
{
"message" => "[09/Jan/2015:00:10:17 +0000] 100.20.10.11 xff=100.40.11.3",
"@version" => "1",
"@timestamp" => "2015-01-20T15:30:10.869Z",
"host" => "Salvador",
"path" => "/tmp/jboss-logs.log",
"type" => "jboss_access",
"tags" => [
[0] "_grokparsefailure"
]
}
로그의 'xff'키에 ip 또는 '-'가 포함될 수 있습니다. 다음 패턴도 시도해 보았습니다. 그러나 그들은 너무 일하지 않았다.
ACCESSLOGPARSE \[%{HTTPDATE:timestamp}\] %{IPORHOST:clientip} (?: xff=%{IPORHOST:xffIp}|-)
and
ACCESSLOGPARSE \[%{HTTPDATE:timestamp}\] %{IPORHOST:clientip} (?: xff=%{IPORHOST:xffIp}|xff=-)
이 패턴의 파서에 어떤 문제가 있습니까?
감사합니다. 솔루션이 효과적이었습니다. 그러나 내가 옆에 공간을 두었을 때 "(? :"왜 그런지 알 수 있습니까? 그리고이 패턴 창조물을 완전히 배울 수있는 링크를 나에게 나눠 줄 것입니까? " 실현 가능한 것 – svjn
ELK에 대해 "완전히 배울"수있는 곳이 없습니다. 여기, 블로그, IRC 등에서 조각을 가져와야합니다. 패턴의 경우 소스 코드 (https : // github.com/elasticsearch/logstash/tree/v1.4.2/patterns) 또는 디버거의 패턴 탭 (https://grokdebug.herokuapp.com/) –
감사합니다 @Alain .. :) – svjn