mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Minor fix and tweak for graylog integration (#15455)
* Minor fix and tweak for graylog integration * More flexible in other use cases * fix again?
This commit is contained in:
@@ -97,13 +97,14 @@ class GraylogApi
|
||||
*/
|
||||
public function buildSimpleQuery(?string $search = null, ?Device $device = null): string
|
||||
{
|
||||
$field = Config::get('graylog.query.field');
|
||||
$query = [];
|
||||
if ($search) {
|
||||
$query[] = 'message:"' . $search . '"';
|
||||
}
|
||||
|
||||
if ($device) {
|
||||
$query[] = 'source: ("' . $this->getAddresses($device)->implode('" OR "') . '")';
|
||||
$query[] = $field . ': ("' . $this->getAddresses($device)->implode('" OR "') . '")';
|
||||
}
|
||||
|
||||
if (empty($query)) {
|
||||
|
@@ -111,14 +111,16 @@ class GraylogController extends SimpleTableController
|
||||
$displayTime = $message['message']['timestamp'];
|
||||
}
|
||||
|
||||
$device = $this->deviceFromSource($message['message']['source']);
|
||||
$origin = $this->deviceFromSource($message['message']['gl2_remote_ip']);
|
||||
$source = $this->deviceFromSource($message['message']['source']);
|
||||
$level = $message['message']['level'] ?? '';
|
||||
$facility = $message['message']['facility'] ?? '';
|
||||
|
||||
return [
|
||||
'origin' => $origin ? Url::deviceLink($origin) : htmlspecialchars($message['message']['gl2_remote_ip']),
|
||||
'severity' => $this->severityLabel($level),
|
||||
'timestamp' => $displayTime,
|
||||
'source' => $device ? Url::deviceLink($device) : htmlspecialchars($message['message']['source']),
|
||||
'source' => $source ? Url::deviceLink($source) : htmlspecialchars($message['message']['source']),
|
||||
'message' => htmlspecialchars($message['message']['message'] ?? ''),
|
||||
'facility' => is_numeric($facility) ? "($facility) " . __("syslog.facility.$facility") : $facility,
|
||||
'level' => (is_numeric($level) && $level >= 0) ? "($level) " . __("syslog.severity.$level") : $level,
|
||||
|
@@ -29,6 +29,7 @@ $tmp_output = '
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="severity" data-sortable="false"></th>
|
||||
<th data-column-id="origin">Origin</th>
|
||||
<th data-column-id="timestamp" data-formatter="browserTime">Timestamp</th>
|
||||
<th data-column-id="level">Level</th>
|
||||
<th data-column-id="source">Source</th>
|
||||
|
@@ -57,7 +57,7 @@ if (\LibreNMS\Config::get('enable_syslog') == 1) {
|
||||
}
|
||||
}
|
||||
|
||||
if (\LibreNMS\Config::get('graylog.port')) {
|
||||
if (\LibreNMS\Config::get('graylog.server')) {
|
||||
echo ' | ';
|
||||
if ($vars['section'] == 'graylog') {
|
||||
echo '<span class="pagemenu-selected">';
|
||||
|
@@ -827,6 +827,12 @@ return [
|
||||
'description' => 'Version',
|
||||
'help' => 'This is used to automatically create the base_uri for the Graylog API. If you have modified the API uri from the default, set this to other and specify your base_uri.',
|
||||
],
|
||||
'query' => [
|
||||
'field' => [
|
||||
'description' => 'Query api field',
|
||||
'help' => 'Changes the default field to query graylog API.',
|
||||
],
|
||||
],
|
||||
],
|
||||
'html' => [
|
||||
'device' => [
|
||||
|
@@ -3763,6 +3763,13 @@
|
||||
"other": "Other"
|
||||
}
|
||||
},
|
||||
"graylog.query.field": {
|
||||
"default": "source",
|
||||
"type": "text",
|
||||
"group": "external",
|
||||
"section": "graylog",
|
||||
"order": 10
|
||||
},
|
||||
"group": {
|
||||
"type": "text",
|
||||
"default": "librenms"
|
||||
|
@@ -3,6 +3,7 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-column-id="severity" data-sortable="false"></th>
|
||||
<th data-column-id="origin">{{ __('Origin') }}</th>
|
||||
<th data-column-id="timestamp" data-formatter="browserTime">{{ __('Timestamp') }}</th>
|
||||
<th data-column-id="level" data-sortable="false">{{ __('Level') }}</th>
|
||||
<th data-column-id="source">{{ __('Source') }}</th>
|
||||
|
Reference in New Issue
Block a user