Skip to content

Commit

Permalink
fixes and removed console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
skaliappan committed Sep 11, 2016
1 parent 4168b92 commit a5b2e48
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
7 changes: 5 additions & 2 deletions README.md
Expand Up @@ -20,7 +20,7 @@ Setup
- Download and install Elasticsearch , Logstash and Kibana
- Logtrail is supported and tested with Kibana 4.x [ support for 5.x coming soon! ]
- Install logtrail plugin
- Kibana 4.x : `./bin/kibana plugin -i logtail http...`
- Kibana 4.x : `./bin/kibana plugin -i logtrail -u `
- Configure logstash to receive syslog events
- Start logstash agent with following configuration to recieve syslog events.
```
Expand Down Expand Up @@ -65,4 +65,7 @@ Setup
- Logs & Events from Windows, Java, Python, PHP, Perl, Ruby, Android, Docker, .Net can be shipped using syslog protocol.
- For more configuration options refer to [Papertrail Configuration Help](http://help.papertrailapp.com/).
- Configure logtrail plugin
- After plugin installation, the tail refresh interval and total events fetched per request can be configured in `logtrail.json` located at installaedPlugins/logtrail directory.
- After plugin installation, the tail refresh interval (default every 10 seconds) and max events fetched per request (default 500) can be configured in `logtrail.json` located at installaedPlugins/logtrail directory.
- Event format : Each line displayed in the events view is of format:
`syslog_timestamp syslog_hostname syslog_program:syslog_message`
- Switching back to Kibana main view from logtrail will not work (known bug).
3 changes: 3 additions & 0 deletions TODO.md
@@ -0,0 +1,3 @@
* Explain how it operates in multiple timezones
* Add warning saying Kibana plugins are not officially supported in currently
* Add context based URL routing, so URL copy & paste will work
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -9,8 +9,8 @@ module.exports = function (kibana) {
app: {
title: 'LogTrail',
description: 'Plugin to view, search & tail logs in Kibana',
main: 'plugins/logtrail/app',
url: '/logtrail',
main: 'plugins/logtrail/app',
url: '/app/logtrail',
injectVars: function (server, options) {
let config = server.config();
return {
Expand Down
19 changes: 6 additions & 13 deletions public/app.js
Expand Up @@ -30,7 +30,7 @@ require('ui/routes')

document.title = 'LogTrail - Kibana';

app.controller('logtrail', function ($scope, es, courier, $window, $interval, $http, $document, $timeout) {
app.controller('logtrail', function ($scope, kbnUrl, es, courier, $window, $interval, $http, $document, $timeout) {
$scope.title = 'LogTrail';
$scope.description = 'Plugin to view, search & tail logs in Kibana';
$scope.userSearchText = null;
Expand All @@ -52,6 +52,7 @@ app.controller('logtrail', function ($scope, es, courier, $window, $interval, $h
var config = null;

function init() {
kbnUrl.change('');
checkElasticsearch();
};

Expand Down Expand Up @@ -185,9 +186,10 @@ app.controller('logtrail', function ($scope, es, courier, $window, $interval, $h
}
var firstEventId = null;
if (actions.indexOf('prepend') !== -1) {
removeDuplicatesForPrepend(events);
if (events.length > 0) {
//Need to move scrollbar to old event location
removeDuplicatesForPrepend(events);
//Need to move scrollbar to old event location,
//so note down its id of before model update
firstEventId = $scope.events[0].id;
angular.forEach(events, function (event) {
$scope.events.unshift(event);
Expand All @@ -200,9 +202,9 @@ app.controller('logtrail', function ($scope, es, courier, $window, $interval, $h
if (actions.indexOf('scrollToTop') !== -1) {
$timeout(function () {
window.scrollTo(0,5);
console.log('scrollToTop called');
});
} else if (actions.indexOf('scrollToView') !== -1) {

if (firstEventId !== null) {
//Make sure the old top event in is still in view
$timeout(function () {
Expand All @@ -216,7 +218,6 @@ app.controller('logtrail', function ($scope, es, courier, $window, $interval, $h
} else {
//Bring scroll to bottom
$timeout(function () {
console.log('scroll to bottom');
angular.element('#kibana-body').scrollTop(angular.element('#kibana-body')[0].scrollHeight);
});
//window.scrollTo(0,$(document).height());
Expand Down Expand Up @@ -334,19 +335,12 @@ app.controller('logtrail', function ($scope, es, courier, $window, $interval, $h
}
};

//Initialize scroll on launch
$scope.$on('onRepeatLast', function () {
//angular.element('#kibana-body').scrollTop(angular.element('#kibana-body')[0].scrollHeight);
console.log('onRepeatLast called');
});

angular.element($window).bind('scroll', function (event) {

if (!updateViewInProgress) {
//When scroll bar search bottom
if (angular.element($window).scrollTop() + angular.element($window).height() === angular.element($document).height()) {
if ($scope.events.length > 0) {
console.log('scrollbar reaches buttons');
var lastestEventTimestamp = Date.create($scope.events[$scope.events.length - 1].received_at).getTime();
doSearch('gt', 'asc', ['append','scrollToView'], lastestEventTimestamp);
}
Expand Down Expand Up @@ -396,7 +390,6 @@ app.controller('logtrail', function ($scope, es, courier, $window, $interval, $h
function setupHostsList() {
$http.get('/logtrail/hosts').then(function (resp) {
if (resp.data.ok) {
console.log(resp.data.resp);
$scope.hosts = resp.data.resp;
} else {
console.error('Error while fetching hosts : ' , resp.data.resp.msg);
Expand Down
4 changes: 2 additions & 2 deletions server/routes/server.js
Expand Up @@ -113,7 +113,7 @@ module.exports = function (server) {
/*//Set sorting column to timestamp
searchRequest.body.sort[0][config.es.timefield] = {'order':'asc','unmapped_type': 'boolean'};*/
}
console.log(JSON.stringify(searchRequest));
//console.log(JSON.stringify(searchRequest));
callWithRequest(request,'search',searchRequest).then(function (resp) {
reply({
ok: true,
Expand Down Expand Up @@ -151,7 +151,7 @@ module.exports = function (server) {
}
};
callWithRequest(request,'search',hostAggRequest).then(function (resp) {
console.log(resp.aggregations.hosts.buckets);
//console.log(resp.aggregations.hosts.buckets);
reply({
ok: true,
resp: resp.aggregations.hosts.buckets
Expand Down
11 changes: 6 additions & 5 deletions syslog.conf
@@ -1,14 +1,14 @@
input {
tcp {
port => 5000
port => 5000 # syslog port. can be changed
type => syslog
}
udp {
udp { #optional. required if syslog events are sent using UDP.
port => 5000
type => syslog
}
}

#Do not change the contents of filter codec
filter {
if [type] == "syslog" {
grok {
Expand All @@ -23,6 +23,7 @@ filter {
}

output {
elasticsearch { hosts => ["localhost:9200"] }
stdout { codec => rubydebug }
elasticsearch {
hosts => ["localhost:9200"] #change host as required
}
}

0 comments on commit a5b2e48

Please sign in to comment.