Use this library to build a beats in PHP, implements lumberjack 2 protocol (a sender to logstash/filebeat). Supports compression and TLS
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
composer.json
composer.lock
example.php

README.md

libbeat-php

Use this library to build a beats in PHP, implements lumberjeck 2 protocol. Supports compression and TLS

How to use?

To use this library you only need to add it to your composer file running:

composer require berni69/libbeat

Once installed, you can send a "beat" as follows:

<?php
require __DIR__.'/vendor/autoload.php';

use libbeat\BeatSender;
$beat = new  BeatSender('192.168.26.12', 5044);
$beat->send("test_log");
$beat->set_compression_rate(0);
$beat->send(["test_log2", "test_log3"]);

To use TLS/SSL you must pass the context options (http://php.net/manual/en/context.ssl.php) to the BeatSender constructor as follows:

<?php
$options = array(
             "ssl" => array(
                 "local_cert"        => $MYCERT,
                 /* If the certificate we are providing was passphrase encoded, we need to set it here */
                 "passphrase"        => "My Passphrase for the local_cert",
         
                 /* Optionally verify the server is who he says he is */
                 "cafile"            => $SSL_DIR . "/" . $SSL_FILE,
                 "allow_self_signed" => false,
                 "verify_peer"       => true,
                 "verify_peer_name"  => true,
                 "verify_expiry"     => true,
             ));
$beat = new  BeatSender('192.168.26.12', 5044, $options);