Simple graylog integration #1665

merged 9 commits into from Aug 18, 2015


None yet

3 participants

laf commented Aug 11, 2015

The config options will now be shown as crossed out but still visable for those who want to set things up in config.php but has a message at the start to direct people to use the WebUI.

Docs also for setting up graylog integration.

Widget added as well for graylog data.

laf added some commits Aug 10, 2015
@laf laf Added graylog support 06430a9
@laf laf Added docs on using Grallog integration
@laf laf added the Enhancement label Aug 11, 2015
@laf laf Added accept header to call to graylog api
f0o commented Aug 15, 2015

Schema-file collides, please bump it to 063 :)

@laf laf updated sql file #
laf commented Aug 16, 2015


f0o commented Aug 16, 2015

Got it in my install and have a couple of notes:

  • My graylog, by default, didnt provide FQDN. I had to add force rdns in the input/s to obtain it. So i was unable to seqrch by device until that change. Should be doc'd.
    • although being able to filter logs after above change, I cant click on the hostname to link me to the devices page, i'd appreciate this link.
    • expand search! Could we just passthrough a searchbox that accepts same syntax as graylog?

Generally this PR is already mergeworthy. It does a good job giving an overview of the last N logmessages. Ofc it doesnt replace graylog.

laf added some commits Aug 17, 2015
@laf laf Updated to use ip for source as well
@laf laf Added devices graylog page - had to force as .gitignore excludes this!
@laf laf Make url from source
laf commented Aug 17, 2015

I've updated to use ip from the hostname, this means it has to resolve the correct IP for the hostname of the device.

Anything more than this is going to be difficult as we can't do a lookup for details in the database otherwise we will be performing an sql query for every log entry.

I've also made the source clickable, however this will only work if it's hostnames as we have no way to get to a device via IP and we can't get the ID without doing an sql query on all the log entries.

The search can be expanded, my testing is limited due to having to do this all on my laptop so best getting this out there for others to contribute to.

ofc it's not supposed to replace graylog, it's simple integration so you can grab the logs directly for a device or view the graylog logs. It can be expanded further so hopefully this is just the start and others can contribute to improve.

f0o commented Aug 17, 2015


laf commented Aug 18, 2015

Source is now clickable.

@f0o f0o commented on an outdated diff Aug 18, 2015
+$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' => generate_url(array('page'=>'device', 'device'=>$message['message']['source'])),
f0o Aug 18, 2015 Member

Please set the source to:
'<a href="'.generate_url(array('page'=>'device', 'device'=>$message['message']['source']))'">'.$message['message']['source'].'</a>'

@f0o f0o merged commit fdf1610 into librenms:master Aug 18, 2015

1 check passed

Scrutinizer 2 new issues
@laf laf deleted the laf:issue-381 branch Jan 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment