Index channel logs in elasticsearch #89

Closed
wants to merge 3 commits into
from
Jump to file or symbol
Failed to load files and symbols.
+19 −1
Diff settings

Always

Just for now

@@ -23,6 +23,11 @@ if (Meteor.isServer) {
locks = Meteor.require('locks');
} catch (err) {
locks = require('locks');
+ }
+ try {
+ elasticsearch = Npm.require('elasticsearch');
+ } catch (err) {
+ elasticsearch = require('elasticsearch');
}
crypto = Npm.require('crypto');
Map = Meteor.require('collections/map');
View
@@ -214,6 +214,17 @@ ChannelLogsManager = function () {
function _insert (log) {
ChannelLogs.insert(log, function (err, id) {});
OldChannelLogs.insert(log, function (err, id) {});
+ if (CONFIG.ENABLE_ELASTIC_SEARCH) {
+ var esClient = elasticsearch.Client({
+ host: CONFIG.ELASTIC_SEARCH_HOST
+ });
+ esClient.index({
+ index: 'channel_logs',
+ type: 'log',
+ body: log
+ }, function (err, resp) {
+ });
+ }
}
return {
insertIfNeeded: function (log, client_nick) {
@@ -17,7 +17,9 @@ CONFIG = {
'IDENT_FILE_PATH': '<path_to_home_dir>/.oidentd.conf',
'LOGS_SCROLLBACK_COUNT': 500,
'CHANNEL_LOGS_COLLECTION_LIMIT_PER_CHANNEL': 1000,
- 'CHANNEL_LOGS_CLEANUP_INTERVAL': 4 * 3600 * 1000
+ 'CHANNEL_LOGS_CLEANUP_INTERVAL': 4 * 3600 * 1000,
+ 'ENABLE_ELASTIC_SEARCH': true,
+ 'ELASTIC_SEARCH_HOST': 'localhost:9200'
}
SUPER_USER = 'admin'