PHP code example of pxlwidgets / legacy-filebeat-emulator
1. Go to this page and download the library: Download pxlwidgets/legacy-filebeat-emulator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pxlwidgets / legacy-filebeat-emulator example snippets
use PXLWidgets\FilebeatEmulator\Config\Config;
use PXLWidgets\FilebeatEmulator\Config\SourceConfig;
use PXLWidgets\FilebeatEmulator\Config\ProcessConfig;
use PXLWidgets\FilebeatEmulator\Config\TargetConfig;
use PXLWidgets\FilebeatEmulator\Process\LogProcessorFactory;
// Provide log paths using glob wildcard patterns to define which logs should be processed.
$logPaths = ['/home/some/path/log-*.txt', '/other/path/*.log'];
// Determine where the processing status file should be stored.
// This file marks up to where the log was previously processed successfully.
$statusPath = '/home/tmp/status.txt';
// The ElasticSearch index that should be used (added under root 'index' key).
$index = 'your-project-acceptance';
// The name for the environment in which your application runs.
$environment = 'acceptance';
// A friendly name for your application (added under root 'application' key).
$application = 'My testing application';
// Any extra data that will be added to all log records sent. This will not overwrite values for keys that are set explicitly.
$extra = [
'your-key' => 'your value',
];
// The URI where you want to send the log entries to.
$host = 'localhost:5000';
// The (Basic Auth) user and password that you want to use.
$user = null;
$password = null;
// Headers to send along with the curl call. For example, if you're going to send JSON data, set the correct Content-Type:
$headers = [
'Content-Type' => 'application/json',
];
$config = new Config(
new SourceConfig($logPaths, $statusPath),
new TargetConfig($host, $user, $password, $headers),
new ProcessConfig($index, $environment, $application, $extra)
);
$processor = (new LogProcessorFactory())->make($config);
$processor->process();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.