nulpunkt / monolog-elasticsearch-logstashformat
Use the logstash formatter with elasticsearch
Installs: 62 572
Dependents: 1
Suggesters: 0
Security: 0
Stars: 34
Watchers: 5
Forks: 13
Open Issues: 0
Requires
- php: >=5.3.0
- elasticsearch/elasticsearch: ~1.0
- monolog/monolog: 1.*
This package is auto-updated.
Last update: 2024-11-17 14:38:29 UTC
README
This handler lets you put logs into Elasticsearch in the Logstash format, which makes visualization with Kibana very easy.
Recommended setup
$client = new Elasticsearch\Client(['hosts' => ['http://example.com:9200']]); $formatter = new Monolog\Formatter\LogstashFormatter('application', null, null, '', 1); $handler = new Monolog\ElasticLogstashHandler($client, ['type' => 'invoicing-logs']); $handler->setFormatter($formatter); $log = new Monolog\Logger('invoicing'); $log->pushHandler($handler); $log->warn('new sale', ['user_id' => 42, 'product_id' => 7537]);