Last active
July 26, 2019 15:06
-
-
Save dzungtran/c3b441dc847c3d76df12d83600105e74 to your computer and use it in GitHub Desktop.
Logstash config for laravel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
input { | |
#logstash -f logstash.conf < request.log > output.txt | |
stdin { | |
type => "laravel_logs" | |
codec => multiline { | |
pattern => "^\[" | |
what => "previous" | |
negate => true | |
} | |
} | |
} | |
filter { | |
if [type] == "laravel_logs" { | |
grok { | |
match => ["message", "\[%{GREEDYDATA:timestamp}\] local.%{DATA:level}: %{GREEDYDATA:context}"] | |
} | |
date { | |
locale => "en" | |
match => [ "timestamp", "YYYY-MM-dd HH:mm:ss" ] | |
timezone => "UTC" | |
} | |
if [level] == "INFO" { | |
grok { | |
tag_on_failure => ["custom_info_log"] | |
match => ["context", "%{DATA:event_name}_%{DATA:event_id} %{GREEDYDATA:str_data}"] | |
remove_field => ["context","message"] | |
} | |
json { | |
skip_on_invalid_json => true | |
source => "str_data" | |
target => "json" | |
remove_field => ["str_data"] | |
} | |
} | |
if [level] == "ERROR" { | |
grok { | |
tag_on_failure => ["custom_error_log"] | |
match => ["context", "exception \'%{DATA:exception}\' with message \'%{DATA:exception_message}\' in %{DATA:exception_line}\nStack trace:\n%{GREEDYDATA:trace_as_string}"] | |
remove_field => ["context","message"] | |
} | |
} | |
} | |
} | |
output { | |
stdout { | |
codec => "rubydebug" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[2015-10-22 13:41:16] local.INFO: I am an info message | |
[2015-10-22 13:41:16] local.NOTICE: I am a notice message | |
[2015-10-22 13:41:16] local.WARNING: I am a warning message | |
[2015-10-22 13:41:16] local.ERROR: I am an ERROR | |
[2015-10-22 13:41:16] local.CRITICAL: Seriously bad error message | |
[2015-10-22 13:41:16] local.ALERT: I am an alert | |
[2017-10-10 17:00:51] local.ERROR: Route_as23b231 No payload {"exception":"[object] | |
[2017-10-13 16:07:11] local.INFO: Route_as23b231 {"js_object":{"id":1111,"name":"dzung"},"js_array":["a","b","c"],"json_string":"{\"obj\":{\"id\":1111,\"name\":\"dzung\"},\"array\":[\"a\",\"b\",\"c\"]}"} | |
[2015-10-22 13:31:56] local.ERROR: exception 'ReflectionException' with message 'Class App\Console\Commands\TestLog does not exist' in /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Container/Container.php:737 | |
Stack trace: | |
#0 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Container/Container.php(737): ReflectionClass->__construct('App\\Console\\Com...') | |
#1 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Container/Container.php(627): Illuminate\Container\Container->build('App\\Console\\Com...', Array) | |
[2017-10-13 16:07:11] local.INFO: Route_as23b231 {"obj":"[object] (stdClass: {\"id\":1111,\"name\":\"dzung\"})"} | |
[2015-10-22 13:31:56] local.ERROR: exception 'ReflectionException' with message 'Class App\Console does not exist' in /Users/test/vendor/laravel//Container/Container.php:121 | |
Stack trace: | |
#0 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Container/Container.php(737): ReflectionClass->__construct('App\\Console\\Com...') | |
#1 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Container/Container.php(627): Illuminate\Container\Container->build('App\\Console\\Com...', Array) | |
#2 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('App\\Console\\Com...', Array) | |
#3 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Console/Application.php(109): Illuminate\Foundation\Application->make('App\\Console\\Com...') | |
#4 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Console/Application.php(123): Illuminate\Console\Application->resolve('App\\Console\\Com...') | |
#5 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(226): Illuminate\Console\Application->resolveCommands(Array) | |
#6 /Users/scott/Downloads/tmp/logstash-test/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Illuminate\Foundation\Console\Kernel->getArtisan() | |
#7 /Users/scott/Downloads/tmp/logstash-test/artisan(36): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) | |
#8 {main} | |
[2015-10-22 13:41:16] local.DEBUG: I'm a debug message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment