clearcode / simple-bus-elk-bundle
ELK integration for Symfony2
Installs: 1 891
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 11
Forks: 0
Open Issues: 0
Type:bundle
Requires
- php: >=5.6
- jms/serializer-bundle: ~1.1
- psr/log: ^1.0
- simple-bus/message-bus: ~2.0
- symfony/framework-bundle: ~2.5
- symfony/monolog-bundle: ~2.4
Requires (Dev)
- phpunit/phpunit: ~5.0
- satooshi/php-coveralls: ^0.7.1
This package is not auto-updated.
Last update: 2024-11-09 19:45:34 UTC
README
ELK Bridge for Symfony2
How to use:
Requirements:
ELK installed, Logstash config:
input {
tcp {
port => 5000
codec => "json"
}
}
output {
elasticsearch { }
}
Tested on ELK docker: https://github.com/deviantony/docker-elk
Installation & configuration:
I. Register a bundle
<?php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( ... new Clearcode\SimpleBusElkBundle\SimpleBusElkBundle(), ... ) } ... }
II. Add this line to your config file:
simple_bus_elk: middleware: true logstash_namespace: your_app monolog_channel: simple_bus_elk monolog: channels: ["simple_bus_elk"] handlers: simple_bus_logstash: type: socket connection_string: localhost:5000 // <-- this part can be parametrized! level: debug channels: ["simple_bus_elk"] formatter: simple_bus_elk.monolog.logstash_formatter // <-- you can use our default, beautiful formatter or write your own if you want to!
III. Enable monolog logger in service:
-
If you are using SimpleBus bundle just set
simple_bus_elk.middleware
totrue
. It will enable Event middleware which will log your events automatically on ELK. -
Otherwise, just use our monolog channel as follow:
services: service.do_amazing_thing: ... arguments: ... - @logger tags: ... - { name: monolog.logger, channel: '%simple_bus_elk.channel%' }
(see Clearcode\SimpleBusElkBundle\CommandBus\LogEventMiddleware as example)
Note:
simple_bus_elk.logstash_namespace
will be logged in @type
field in Kibana. We suggest to change it to name of project, from which you want to log events
(it is important especially if you want to log events from more than one project in one ELK instance).
simple_bus_elk.channel
will be logged in @fields.channel
& @tags
fields in Kibana. It is important when you log something else in ELK instance
at the same Kibana's index pattern.