Created
November 12, 2019 09:57
-
-
Save andybeak/5ab3def0fb060e6d6b5045bda4de5571 to your computer and use it in GitHub Desktop.
Blog article on monolog to ELK #blog
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
<?php | |
require('../vendor/autoload.php'); | |
use Monolog\Logger; | |
use Monolog\Handler\SocketHandler; | |
// create a log channel | |
$log = new Logger('elk'); | |
// "logstash" is a host defined by docker-compose | |
$handler = new SocketHandler('logstash:9001', Logger::DEBUG); | |
$log->pushHandler($handler); |
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 { | |
tcp { | |
port => 9001 | |
} | |
} | |
# See https://grokdebug.herokuapp.com/ and https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns | |
filter { | |
grok { | |
match => { "message" => "\[%{TIMESTAMP_ISO8601:timestamp}\] %{DATA:env}\.%{DATA:severity}: %{GREEDYDATA:message} (?<context>(\{.*?\})) \[\]" } | |
} | |
} | |
filter { | |
json { | |
source => "context" | |
} | |
} | |
output { | |
stdout {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment