-
Notifications
You must be signed in to change notification settings - Fork 13
/
logs.js
22 lines (18 loc) · 990 Bytes
/
logs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';
const _ = require('lodash');
const Promise = require('bluebird');
const { getClient } = require('@terascope/job-components');
module.exports = function logsStorage(context) {
if (_.includes(context.sysconfig.terafoundation.logging, 'elasticsearch')) {
const client = getClient(context, context.sysconfig.teraslice.state, 'elasticsearch');
const template = require('./backends/mappings/logs.json');
const elasticsearch = require('@terascope/elasticsearch-api')(client, context.logger, null);
const clusterName = context.sysconfig.teraslice.name;
const name = `${clusterName}_logs_template`;
// setting template name to reflect current teraslice instance name to help prevent
// conflicts with differing versions of teraslice with same elastic db
template.template = `${clusterName}${template.template}`;
return elasticsearch.putTemplate(template, name);
}
return Promise.resolve(true);
};