query-logentries

Query logentries.com via their REST API. Returns only the raw log messages you passed to logEntries at the time of logging. Supports both callback and streaming and uses request-retry-stream internally to make requests in order to be more robust in case of network glitches.
Installation
npm install --save query-logentries
Usage
How to initialize and available options:
const queryLogentriesFactory = require('query-logentries');
const apiKey = '6971aef7-998f-4cb2-9613-ddb42b9697b8';
const queryUrl = 'https://rest.logentries.com/query/logs';
const queryLogentries = queryLogentriesFactory(apiKey, queryUrl);
const opts = {
logId: '7d9ff278-3a6d-4c7a-8e65-df89fd3f5a96',
from: '2017-01-01T00:00:00.000',
to: '2017-01-02T23:59:59.999',
query: 'where(method=GET)',
perPage: 50,
timeout: 30000,
pollInterval: 3000
};
After initializing, using it with callback:
queryLogentries(opts, (err, messages) => {
if (err) {
return;
}
console.log('messages', messages);
});
After initializing, using it with streaming:
const pump = require('pump');
const through2 = require('through2');
const fs = require('fs');
const logEntriesStream = queryLogentries(opts);
const toStringStream = through2.obj(function(message, enc, callback) {
this.push(JSON.stringify(message) + '\n');
callback();
});
const toFileStream = fs.createWriteStream('./result.txt');
pump(logEntriesStream, toStringStream, toFileStream, err => {
if (err) {
}
});
License
MIT