Comparing version 0.3.3 to 0.4.0
{ | ||
"name": "eslogs", | ||
"version": "0.3.3", | ||
"version": "0.4.0", | ||
"description": "A command-line tool for searching logs stored in elasticsearch.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,2 +29,3 @@ Introduction | ||
eslogs logstash-* -q "192.168.1.100" | ||
eslogs logstash-* -q "\"192.168.1.100\" AND error" | ||
eslogs logstash-* -q "failed with error" | ||
@@ -31,0 +32,0 @@ eslogs logstash-* -q error -t "24 hours ago" |
@@ -20,2 +20,3 @@ let args = require('minimist')(process.argv.slice(2)); | ||
eslogs logstash-* -q "192.168.1.100" | ||
eslogs logstash-* -q "\\"192.168.1.100\\" AND error" | ||
eslogs logstash-* -q "failed with error" | ||
@@ -58,3 +59,3 @@ eslogs logstash-* -q error -t "24 hours ago" | ||
size: args.s || 100, | ||
query: args.q | ||
query: `"${args.q}"` // surround in quotes for es | ||
}; | ||
@@ -61,0 +62,0 @@ } |
@@ -6,2 +6,3 @@ let dateFns = require('date-fns'); | ||
let config = require('./config'); | ||
let { buildSearch } = require('./searchHelper'); | ||
@@ -50,22 +51,7 @@ let { | ||
return client.search({ | ||
index, | ||
scroll: '30s', | ||
_source: [timestampKey, hostnameKey, messageKey], | ||
body: { | ||
query: { | ||
bool: { | ||
must | ||
} | ||
}, | ||
sort: [ | ||
{ | ||
[timestampKey]: { | ||
order: 'asc' | ||
} | ||
} | ||
] | ||
}, | ||
size: size > 10000 ? 10000 : size | ||
}); | ||
let searchBody = buildSearch( | ||
query, index, size, hostname, time, messageKey, timestampKey, hostnameKey | ||
); | ||
return client.search(searchBody); | ||
} | ||
@@ -117,3 +103,6 @@ | ||
if (messages.length) { | ||
console.log(messages.join('\n')); | ||
// we reverse here because we sort descending in the search | ||
// to get the most recent x results, | ||
// but we want to show to the user in ascending order | ||
console.log(messages.reverse().join('\n')); | ||
} | ||
@@ -120,0 +109,0 @@ } |
9538
10
282
58