PHP code example of comcast / splunk-http-event-collector-handler

1. Go to this page and download the library: Download comcast/splunk-http-event-collector-handler 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/ */

    

comcast / splunk-http-event-collector-handler example snippets


use Comcast\SplunkHttpEventCollectorHandler\SplunkClient;

$client = new SplunkClient();
if (!$client->sendEvent([
    'event' => [
        'your data here',
    ],
    'index' => 'my-index', // You can set the index for this request here, or use the default for your HEC Token
    'sourcetype' => 'my-sourcetype', // You can set the sourcetype for this request here, or use the default for your HEC Token
])) {
    $error = $client->getError();
}

'channels' => [
    'stack' => [
        'driver' => 'stack',
        'channels' => ['syslog', 'slack'],
    ],
'splunk_hec' =>
    'syslog' => [
        'driver' => 'syslog',
        'level' => 'debug',
    ],

    'slack' => [
        'driver' => 'slack',
        'url' => env('LOG_SLACK_WEBHOOK_URL'),
        'username' => 'Laravel Log',
        'emoji' => ':boom:',
        'level' => 'critical',
    ],
],

// use Comcast\SplunkHttpEventCollectorHandler\Handlers\LaravelHandler;
'channels' => [
    'splunk_hec' => [
        'driver' => 'monolog',
        'level' => 'debug',
        'handler' => LaravelHandler::class,
    ],
]