diff --git a/doc/Extensions/Graylog.md b/doc/Extensions/Graylog.md
new file mode 100644
index 000000000..32d0ab1cd
--- /dev/null
+++ b/doc/Extensions/Graylog.md
@@ -0,0 +1,17 @@
+# Graylog integration
+
+We have simple integration for Graylog, you will be able to view any logs from within LibreNMS that have been parsed by the syslog input from within
+Graylog itself. This includes logs from devices which aren't in LibreNMS still, you can also see logs for a sepcific device under the logs section
+for the device.
+
+Graylog itself isn't included within LibreNMS, you will need to install this separately either on the same infrastructure as LibreNMS or as a totally
+standalone appliance.
+
+Config is simple, here's an example:
+
+```php
+$config['graylog']['server'] = 'http://127.0.0.1';
+$config['graylog']['port'] = 12900;
+$config['graylog']['username'] = 'admin';
+$config['graylog']['password'] = 'admin';
+```
diff --git a/html/ajax_dash.php b/html/ajax_dash.php
index e25994282..3b4c56e46 100644
--- a/html/ajax_dash.php
+++ b/html/ajax_dash.php
@@ -33,6 +33,8 @@ if ($type == 'placeholder') {
}
elseif (is_file('includes/common/'.$type.'.inc.php')) {
+ $results_limit = 10;
+ $no_form = true;
include 'includes/common/'.$type.'.inc.php';
$output = implode('', $common_output);
$status = 'ok';
diff --git a/html/includes/common/graylog.inc.php b/html/includes/common/graylog.inc.php
new file mode 100644
index 000000000..0d24e8406
--- /dev/null
+++ b/html/includes/common/graylog.inc.php
@@ -0,0 +1,125 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version. Please see LICENSE.txt at the top level of
+ * the source code distribution for details.
+ */
+
+if (empty($results_limit)) {
+ $results_limit = 25;
+}
+$tmp_output = '
Graylog
+
+
+
+
+
+ | Timestamp |
+ Source |
+ Message |
+ Facility |
+ Level |
+
+
+
+
+
+
+
+';
+
+$common_output[] = $tmp_output;
diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php
index c436d5b7d..06b4ffb04 100644
--- a/html/includes/print-menubar.php
+++ b/html/includes/print-menubar.php
@@ -77,9 +77,17 @@ if ($_SESSION['userlevel'] >= '10') {
Eventlog
- Syslog');
-} ?>
+ Syslog';
+}
+
+if (isset($config['graylog']['server']) && isset($config['graylog']['port'])) {
+ echo ' Graylog';
+}
+
+?>
Inventory
diff --git a/html/includes/table/graylog.inc.php b/html/includes/table/graylog.inc.php
new file mode 100644
index 000000000..b56b1402b
--- /dev/null
+++ b/html/includes/table/graylog.inc.php
@@ -0,0 +1,71 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or (at your
+ * option) any later version. Please see LICENSE.txt at the top level of
+ * the source code distribution for details.
+ */
+
+$filter_hostname = mres($_POST['hostname']);
+$filter_range = mres($_POST['range']);
+
+if (isset($searchPhrase) && !empty($searchPhrase)) {
+ $query = 'message:"'.$searchPhrase.'"';
+}
+else {
+ $query = '*';
+}
+
+if (isset($current)) {
+ $offset = ($current * $rowCount) - ($rowCount);
+ $limit = $rowCount;
+}
+
+if ($rowCount != -1) {
+ $extra_query = "&limit=$limit&offset=$offset";
+}
+
+if (!empty($filter_hostname)) {
+ if (!empty($query)) {
+ $query .= ' && ';
+ }
+ $ip = gethostbyname($filter_hostname);
+ $query .= 'source:"'.$filter_hostname.'" || source:"'.$ip.'"';
+}
+
+$graylog_url = $config['graylog']['server'] . ':' . $config['graylog']['port'] . '/search/universal/relative?query=' . urlencode($query) . '&range='. $filter_range . $extra_query;
+
+$context = stream_context_create(array(
+ 'http' => array(
+ 'header' => "Authorization: Basic " . base64_encode($config['graylog']['username'].':'.$config['graylog']['password']) . "\r\n" .
+ "Accept: application/json",
+ )
+));
+
+$messages = json_decode(file_get_contents($graylog_url, false, $context),true);
+
+foreach ($messages['messages'] as $message) {
+ $response[] = array(
+ 'timestamp' => $message['message']['timestamp'],
+ 'source' => ''.$message['message']['source'].'',
+ 'message' => $message['message']['message'],
+ 'facility' => $message['message']['facility'],
+ 'level' => $message['message']['level'],
+ );
+}
+
+if (empty($messages['total_results'])) {
+ $total = 0;
+}
+else {
+ $total = $messages['total_results'];
+}
+
+$output = array('current'=>$current,'rowCount'=>$rowCount,'rows'=>$response,'total'=>$total);
+echo _json_encode($output);
diff --git a/html/pages/device/logs.inc.php b/html/pages/device/logs.inc.php
index 11fd6914b..81fea25a1 100644
--- a/html/pages/device/logs.inc.php
+++ b/html/pages/device/logs.inc.php
@@ -30,9 +30,21 @@ if (isset($config['enable_syslog']) && $config['enable_syslog'] == 1) {
}
}
+if (isset($config['graylog']['server']) && isset($config['graylog']['port'])) {
+ echo ' | ';
+ if ($vars['section'] == 'graylog') {
+ echo '';
+ }
+}
+
switch ($vars['section']) {
case 'syslog':
case 'eventlog':
+ case 'graylog':
include 'pages/device/logs/'.$vars['section'].'.inc.php';
break;
diff --git a/html/pages/device/logs/graylog.inc.php b/html/pages/device/logs/graylog.inc.php
new file mode 100644
index 000000000..19e0d6115
--- /dev/null
+++ b/html/pages/device/logs/graylog.inc.php
@@ -0,0 +1,5 @@
+