Skip to content

Instantly share code, notes, and snippets.

@kamermans
Last active July 31, 2023 11:31
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save kamermans/f53aa58bbd14a3fff9541b76064efa1a to your computer and use it in GitHub Desktop.
Save kamermans/f53aa58bbd14a3fff9541b76064efa1a to your computer and use it in GitHub Desktop.
Logstash parser for PHP's error_log to combine multline stack traces / errors into one event
input {
stdin {
codec => multiline {
pattern => "^\[%{MONTHDAY}-%{MONTH}-%{YEAR} %{TIME} %{TZ}\]"
negate => true
what => "previous"
auto_flush_interval => 10
}
type => "php-error"
}
}
filter {
grok {
match => { "message" => "^\[(?<logtime>%{MONTHDAY}-%{MONTH}-%{YEAR} %{TIME} %{TZ})\] ?%{GREEDYDATA:message}" }
overwrite => [ "message" ]
}
date {
match => [ "logtime", "d-MMM-yyyy HH:mm:ss ZZZ" ]
remove_field => [ "logtime" ]
}
}
output {
stdout {
codec => rubydebug
}
}
@sonnh-uit
Copy link

How to php-access?

@kamermans
Copy link
Author

Hi @hecma002, this logstash configuration reads a PHP error log file and parses these multi-line messages into single events for further processing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment