Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
42b65c0
Fix filter fields device event and syslog tabs
jepke Dec 9, 2025
15c13e9
Revisit the issue with keep init_select2() approach
jepke Dec 10, 2025
53594cd
Match with the code from #18631
jepke Dec 10, 2025
38348f5
Consistency across all device logs blades
jepke Dec 10, 2025
f194dd5
More room for meaningfull message without device column on device spe…
jepke Dec 10, 2025
7bdbd66
Unintentional
jepke Dec 10, 2025
8dfd6cc
Unintentional
jepke Dec 10, 2025
6877ebe
makes no sense hear
jepke Dec 11, 2025
30ba21c
Refactor eventlog blades
jepke Dec 12, 2025
7fd6971
Syslog pages
jepke Dec 12, 2025
d386854
Fix filter fields device event and syslog tabs
jepke Dec 9, 2025
0223a56
Revisit the issue with keep init_select2() approach
jepke Dec 10, 2025
41fa730
Match with the code from #18631
jepke Dec 10, 2025
dcef14a
Consistency across all device logs blades
jepke Dec 10, 2025
103bd17
More room for meaningfull message without device column on device spe…
jepke Dec 10, 2025
a5b3bbc
Unintentional
jepke Dec 10, 2025
f171b41
Unintentional
jepke Dec 10, 2025
67543c5
makes no sense hear
jepke Dec 11, 2025
0af574d
Refactor eventlog blades
jepke Dec 12, 2025
dda8753
Syslog pages
jepke Dec 12, 2025
53b4ee9
Graylog blades
jepke Dec 14, 2025
e4067ab
rebase
jepke Dec 14, 2025
de3b3f5
fix errors
jepke Dec 14, 2025
71e3e11
cleanup
jepke Dec 14, 2025
fef79af
Device tab graylog
jepke Dec 14, 2025
852e12c
Global graylog page
jepke Dec 14, 2025
b5b18ac
Minors
jepke Dec 14, 2025
744910a
Graylog absolute time filters
jepke Dec 15, 2025
144773a
Event and Syslog export functions
jepke Dec 15, 2025
5ff93cc
Consistency
jepke Dec 15, 2025
3ef29a3
Fix deprecation warning
jepke Dec 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 42 additions & 3 deletions app/ApiClients/GraylogApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,16 @@ public function getStreams(): array
}

/**
* Query the Graylog server
* Query the Graylog server relative time
*/
public function query(string $query = '*', int $range = 0, int $limit = 0, int $offset = 0, ?string $sort = null, ?string $filter = null): array
{
public function queryRelative(
string $query = '*',
int $range = 0,
int $limit = 0,
int $offset = 0,
?string $sort = null,
?string $filter = null
): array {
if (! $this->isConfigured()) {
return [];
}
Expand All @@ -93,6 +99,39 @@ public function query(string $query = '*', int $range = 0, int $limit = 0, int $
return $response->json() ?: [];
}

/**
* Query the Graylog server absolute time
*/
public function queryAbsolute(
string $query = '*',
string $from = '',
string $to = '',
int $limit = 0,
int $offset = 0,
?string $sort = null,
?string $filter = null
): array {
if (! $this->isConfigured()) {
return [];
}

$uri = $this->api_prefix . '/search/universal/absolute';

$data = [
'query' => $query,
'from' => $from,
'to' => $to,
'limit' => $limit,
'offset' => $offset,
'sort' => $sort,
'filter' => $filter,
];

$response = $this->client->get($uri, $data)->throw();

return $response->json() ?: [];
}

/**
* Build a simple query string that searches the messages field and/or filters by device
*/
Expand Down
27 changes: 25 additions & 2 deletions app/Http/Controllers/Device/Tabs/EventlogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@

namespace App\Http\Controllers\Device\Tabs;

use App\Facades\LibrenmsConfig;
use App\Http\Controllers\Controller;
use App\Models\Device;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\View\View;

class EventlogController extends Controller
Expand All @@ -37,12 +39,33 @@ public function __invoke(Device $device, Request $request): View
{
$request->validate([
'eventtype' => 'nullable|string',
'device' => 'nullable|int',
'from' => 'nullable|string',
'to' => 'nullable|string',
]);
$eventlog_filter = [
'field' => 'type',
'device' => $device->device_id,
];

$format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i');
$now = Carbon::now();
$defaultFrom = (clone $now)->subDays(7);
$fromInput = $request->input('from');
$toInput = $request->input('to');

if (empty($fromInput) && empty($toInput)) {
$fromInput = $defaultFrom->format($format);
$toInput = $now->format($format);
}
return view('device.tabs.logs.eventlog', [
'device' => $device,
'filter_device' => false,
'now' => $now->format($format),
'default_date' => $defaultFrom->format($format),
'eventtype' => $request->input('eventtype', ''),
'from' => $fromInput,
'to' => $toInput,
'device' => $device,
'eventlog_filter' => $eventlog_filter,
]);
}
}
23 changes: 23 additions & 0 deletions app/Http/Controllers/Device/Tabs/GraylogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use App\Facades\LibrenmsConfig;
use App\Http\Controllers\Controller;
use App\Models\Device;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\View\View;

Expand All @@ -40,7 +41,24 @@ public function __invoke(Device $device, Request $request): View
'stream' => 'nullable|string',
'range' => 'nullable|int',
'loglevel' => 'nullable|int',
'to' => 'nullable|string',
'level' => 'nullable|string',
]);
$graylog_filter = [
'field' => 'stream',
'device' => $device->device_id,
];

$format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i');
$now = Carbon::now();
$defaultFrom = (clone $now)->subDays(7);
$fromInput = $request->input('from');
$toInput = $request->input('to');

if (empty($fromInput) && empty($toInput)) {
$fromInput = $defaultFrom->format($format);
$toInput = $now->format($format);
}

return view('device.tabs.logs.graylog', [
'device' => $device,
Expand All @@ -50,6 +68,11 @@ public function __invoke(Device $device, Request $request): View
'stream' => $request->input('stream', ''),
'range' => $request->input('range', '0'),
'loglevel' => $request->input('loglevel', ''),
'from' => $fromInput,
'to' => $toInput,
'default_date' => $defaultFrom->format($format),
'now' => $now->format($format),
'graylog_filter' => $graylog_filter,
]);
}
}
32 changes: 27 additions & 5 deletions app/Http/Controllers/Device/Tabs/SyslogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,41 @@ public function __invoke(Device $device, Request $request): View
$request->validate([
'program' => 'nullable|string',
'priority' => 'nullable|string',
'device' => 'nullable|int',
'from' => 'nullable|string',
'to' => 'nullable|string',
'level' => 'nullable|string',
]);
$syslog_program_filter = [
'field' => 'program',
'device' => $device->device_id,
];
$syslog_priority_filter = [
'field' => 'priority',
'device' => $device->device_id,
];

$format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i');
$now = Carbon::now();
$defaultFrom = (clone $now)->subDays(7);
$fromInput = $request->input('from');
$toInput = $request->input('to');

if (empty($fromInput) && empty($toInput)) {
$fromInput = $defaultFrom->format($format);
$toInput = $now->format($format);
}

return view('device.tabs.logs.syslog', [
'device' => $device,
'filter_device' => false,
'now' => Carbon::now()->format(LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i')),
'default_date' => Carbon::now()->subDay()->format(LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i')),
'now' => $now->format($format),
'default_date' => $defaultFrom->format($format),
'program' => $request->input('program', ''),
'priority' => $request->input('priority', ''),
'from' => $request->input('from', ''),
'to' => $request->input('to', ''),
'from' => $fromInput,
'to' => $toInput,
'syslog_program_filter' => $syslog_program_filter,
'syslog_priority_filter' => $syslog_priority_filter,
]);
}
}
57 changes: 57 additions & 0 deletions app/Http/Controllers/EventlogController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php

namespace App\Http\Controllers;

use App\Facades\LibrenmsConfig;
use App\Http\Controllers\Controller;
use App\Models\Device;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\View\View;

class EventlogController extends Controller
{
public function __invoke(Request $request): View
{
$this->validate($request, [
'eventtype' => 'nullable|string',
'device' => 'nullable|int',
'from' => 'nullable|string',
'to' => 'nullable|string',
]);

$device = \App\Models\Device::hasAccess($request->user())
->select(['device_id', 'hostname', 'ip', 'sysName', 'display'])
->firstWhere('device_id', $request->input('device'));

$eventlog_filter = ['field' => 'type'];
$device_selected = '';
if ($device) {
$device_selected = ['id' => $device->device_id, 'text' => $device->displayName()];
$eventlog_filter['device'] = $device->device_id;
}

$format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i');
$now = Carbon::now();
$defaultFrom = (clone $now)->subDays(1);
$fromInput = $request->input('from');
$toInput = $request->input('to');

if (empty($fromInput) && empty($toInput)) {
$fromInput = $defaultFrom->format($format);
$toInput = $now->format($format);
}
return view('eventlog', [
'device' => $device_selected,
'filter' => [
'now' => $now->format($format),
'default_date' => $defaultFrom->format($format),
'eventtype' => $request->input('eventtype', ''),
'from' => $fromInput,
'to' => $toInput,
'device' => $device?->device_id,
],
'eventlog_filter' => $eventlog_filter,
]);
}
}
64 changes: 64 additions & 0 deletions app/Http/Controllers/GraylogController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace App\Http\Controllers;

use App\Facades\LibrenmsConfig;
use App\Http\Controllers\Controller;
use App\Models\Device;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\View\View;

class GraylogController extends Controller
{
public function __invoke(Request $request): View
{
$request->validate([
'stream' => 'nullable|string',
'device' => 'nullable|int',
'range' => 'nullable|int',
'loglevel' => 'nullable|int',
'to' => 'nullable|string',
'level' => 'nullable|string',
]);

$device = \App\Models\Device::hasAccess($request->user())
->select(['device_id', 'hostname', 'ip', 'sysName', 'display'])
->firstWhere('device_id', $request->input('device'));

$graylog_filter = ['field' => 'stream',];
$device_selected = '';
if ($device) {
$device_selected = ['id' => $device->device_id, 'text' => $device->displayName()];
$graylog_filter['device'] = $device->device_id;
}

$format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i');
$now = Carbon::now();
$defaultFrom = (clone $now)->subDays(1);
$fromInput = $request->input('from');
$toInput = $request->input('to');

if (empty($fromInput) && empty($toInput)) {
$fromInput = $defaultFrom->format($format);
$toInput = $now->format($format);
}

return view('graylog', [
'device' => $device_selected,
'filter' => [
'timezone' => LibrenmsConfig::has('graylog.timezone'),
'filter_device' => true,
'show_form' => true,
'stream' => $request->input('stream', ''),
'range' => $request->input('range', '0'),
'loglevel' => $request->input('loglevel', ''),
'from' => $fromInput,
'to' => $toInput,
'default_date' => $defaultFrom->format($format),
'now' => $now->format($format),
],
'graylog_filter' => $graylog_filter,
]);
}
}
65 changes: 65 additions & 0 deletions app/Http/Controllers/SyslogController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php

namespace App\Http\Controllers;

use App\Facades\LibrenmsConfig;
use App\Http\Controllers\Controller;
use App\Models\Device;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\View\View;

class SyslogController extends Controller
{
public function __invoke(Request $request): View
{
$request->validate([
'program' => 'nullable|string',
'priority' => 'nullable|string',
'device' => 'nullable|int',
'from' => 'nullable|string',
'to' => 'nullable|string',
'level' => 'nullable|string',
]);

$device = \App\Models\Device::hasAccess($request->user())
->select(['device_id', 'hostname', 'ip', 'sysName', 'display'])
->firstWhere('device_id', $request->input('device'));

$syslog_program_filter = ['field' => 'program'];
$syslog_priority_filter = ['field' => 'priority'];
$device_selected = '';
if ($device) {
$device_selected = ['id' => $device->device_id, 'text' => $device->displayName()];
$syslog_program_filter['device'] = $device->device_id;
$syslog_priority_filter['device'] = $device->device_id;
}

$format = LibrenmsConfig::get('dateformat.byminute', 'Y-m-d H:i');
$now = Carbon::now();
$defaultFrom = (clone $now)->subDays(1);
$fromInput = $request->input('from');
$toInput = $request->input('to');

if (empty($fromInput) && empty($toInput)) {
$fromInput = $defaultFrom->format($format);
$toInput = $now->format($format);
}

return view('syslog', [
'device' => $device_selected,
'filter' => [
'device' => $device,
'filter_device' => false,
'now' => $now->format($format),
'default_date' => $defaultFrom->format($format),
'program' => $request->input('program', ''),
'priority' => $request->input('priority', ''),
'from' => $fromInput,
'to' => $toInput,
],
'syslog_program_filter' => $syslog_program_filter,
'syslog_priority_filter' => $syslog_priority_filter,
]);
}
}
Loading