Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Graylog to device overview and log level filter mechanism #10509

Merged
merged 11 commits into from Aug 27, 2019

Conversation

@rsys-dev
Copy link
Contributor

commented Aug 9, 2019

I added Recent Graylog Entries to device overview like Recent Syslog or Events and 2 Config options to influence the behaviour of the "Recent Graylog" table on the overview page of the devices (row count and maximum log level to show).
Also added a log level dropdown to filter existing Graylog Pages (device subpage and graylog overview) and a graylog widget setting to set the maximum log level for the widget.

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

rsys-dev added 7 commits Aug 8, 2019
Improved "Recent Graylog" entries on device overview (WIP)
Added $config['graylog']['device-page']['rowCount'] to set maximum rows shown in "Recent Graylog" on device overview (Default: 10)
Added $config['graylog']['device-page']['maxLevel'] to set the maximum message level shown in "Recent Graylog" on device overview (Default: 7, validates value to be >= 0 and <= 7)
Added Log Level filter to Graylog widget
Added Log Level filter to Graylog pages (device pages and graylog overview)
Removed unneccesary (and already commented) using
Renamed "maxLevel" to "loglevel" as suggested by a colleague
/*
* LibreNMS
*
* Copyright (c) 2014 Neil Lathwood <https://github.com/laf/ http://www.lathwood.co.uk/fa>

This comment has been minimized.

Copy link
@murrant

murrant Aug 12, 2019

Member

Just inline this file in the overview/graylog.inc.php.

Also, you should not be assigning copyright to other people. Please fix in all files.

This comment has been minimized.

Copy link
@rsys-dev

rsys-dev Aug 12, 2019

Author Contributor

Ok, this was copy and paste as I copied print-syslog.inc.php and modified it for Graylog.
Should I add Copyright to overview/graylog.inc.php?
Every other file existed before, because of that I did not change / add any copyright, or should I change anything here?

This comment has been minimized.

Copy link
@murrant

murrant Aug 12, 2019

Member

You may add your copyright on the files, that is up to you. All files will be licensed under GPLv3 as per our license. Individual file license headers are just for good measure.

@@ -31,7 +31,8 @@
return {
stream: "{{ $stream }}",
device: "{{ $device }}",
range: "{{ $range }}"
range: "{{ $range }}",
loglevel: "{{ $loglevel }}",

This comment has been minimized.

Copy link
@murrant

murrant Aug 12, 2019

Member

Javascript json does not allow commas on the last item.

This comment has been minimized.

Copy link
@rsys-dev

rsys-dev Aug 12, 2019

Author Contributor

You are right, changed

<label for="loglevel-{{ $id }}" class="control-label">@lang('Log Level')</label>
<select name="loglevel" id="loglevel-{{ $id }}" class="form-control">
<option value="" disabled @if($loglevel == null) selected @endif>@lang('Log Level')</option>
<option value="0" @if($loglevel === 0) selected @endif>@lang('(0) Emergency')</option>

This comment has been minimized.

Copy link
@murrant

murrant Aug 12, 2019

Member

These should use the translation strings syslog.severity.0

This comment has been minimized.

Copy link
@rsys-dev

rsys-dev Aug 12, 2019

Author Contributor

Changed this. Did not realize (also never tried) that I can use these translation Strings there.

This comment has been minimized.

Copy link
@murrant

murrant Aug 12, 2019

Member

You could even use a foreach so you don't have to repeat every option ;)

This comment has been minimized.

Copy link
@rsys-dev

rsys-dev Aug 12, 2019

Author Contributor

I can't get this to work with the translation strings.

@foreach(range(0, 7) as $level)
  <option value="{{ $level }}" @if($loglevel == $level && $loglevel != null) selected @endif>({{ $level }}) @lang('syslog.severity.{{ $level }}')</option>
@endforeach

Results in a select field with (0) syslog.severity. and so on as options,

@foreach(range(0, 7) as $level)
  <option value="{{ $level }}" @if($loglevel == $level && $loglevel != null) selected @endif>({{ $level }}) @lang('syslog.severity.'{{ $level }})</option>
@endforeach

results in Problem with backend

rsys-dev and others added 4 commits Aug 12, 2019
Removed includes/html/print-graylog.inc.php and inlined it in include…
…s/html/pages/device/overview/graylog.inc.php

Removed comma in json object in resources/views/widgets/graylog.blade.php
Replaced translation strings in resources/views/widgets/settings/graylog.blade.php with existing translation strings
@murrant
Copy link
Member

left a comment

LGTM

@rsys-dev

This comment has been minimized.

Copy link
Contributor Author

commented Aug 27, 2019

Tested and works like expected

@murrant murrant merged commit 3cb971e into librenms:master Aug 27, 2019

4 checks passed

Travis CI - Pull Request Build Passed
Details
WIP Ready for review
Details
codeclimate All good!
Details
license/cla Contributor License Agreement is signed.
Details
@murrant

This comment has been minimized.

Copy link
Member

commented Sep 3, 2019

This pull request has been mentioned on LibreNMS Community. There might be relevant details there:

https://community.librenms.org/t/v1-55-release-changelog-august-2019/9428/1

@rsys-dev rsys-dev deleted the rsys-dev:graylog branch Sep 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.