feat: add basic auth support

This commit is contained in:
2018-11-02 12:11:54 -07:00
parent 0834274166
commit 420c845cbc
2 changed files with 3 additions and 1 deletions

View File

@@ -6,9 +6,10 @@ const mod = require('../src/index.mjs').default;
const logger = require('../src/lib/logger.mjs').default; const logger = require('../src/lib/logger.mjs').default;
const { index, interval, ...elasticsearch } = getopts(process.argv.slice(2), { const { index, interval, ...elasticsearch } = getopts(process.argv.slice(2), {
string: ['host', 'log'], string: ['host', 'auth', 'log', 'index'],
alias: { alias: {
h: 'host', h: 'host',
u: 'auth',
l: 'log', l: 'log',
i: 'index', i: 'index',
t: 'interval', t: 'interval',

View File

@@ -9,6 +9,7 @@ export default async function(indexName, opts = {}) {
const client = new elasticsearch.Client({ const client = new elasticsearch.Client({
host: opts.elasticsearch.host, host: opts.elasticsearch.host,
log: opts.elasticsearch.log, log: opts.elasticsearch.log,
httpAuth: opts.elasticsearch.auth,
}); });
// make sure we can connect to the node // make sure we can connect to the node