pinojs / pino-elasticsearch

🌲 load pino logs into Elasticsearch
MIT License
179 stars 67 forks source link

CLI Support for dynamic index names #48

Closed tylerjwatson closed 3 years ago

tylerjwatson commented 4 years ago

This patch introduces an equivalent dynamic index name support in the CLI version of pino-elastic search via a -r CLI parameter.

-r is analogous to node's require flag in that it allows users of the commandline to specify a module require path that contains a factory function which produces an index in exactly the same fashion as what's already there in the usage as a module section of the documentation.

Usage:

Given I have a factory.js file in the current directory with the following contents:

module.exports = function (date) {
  // return an index name
}

And I use pino-elasticsearch on the commandline according to the following format:

cat log | pino-elasticsearch -r ./factory

Then I will have the index generated as per the function in the ./factory module, in exactly the same fashion as the usage as a module functionality.

tylerjwatson commented 4 years ago

Ah, I looked at that but wasn’t sure whether we could introduce new dependencies. I will integrate that ASAP.

Cheers

Sent from my iPhone

On 26 Feb 2020, at 6:36 pm, Matteo Collina notifications@github.com wrote:



@mcollina commented on this pull request.


In lib.jshttps://github.com/pinojs/pino-elasticsearch/pull/48#discussion_r384338735:

@@ -52,7 +52,7 @@ function pinoElasticSearch (opts) {

const esVersion = Number(opts['es-version']) || 7 const useEcs = !!opts.ecs

please use https://www.npmjs.com/package/resolve-from instead.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/pinojs/pino-elasticsearch/pull/48?email_source=notifications&email_token=ABGFBQHUU2E6D7FKSWGG2OTREYSXXA5CNFSM4K337SZKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCW6OS7Y#pullrequestreview-364702079, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABGFBQD4AVZPDB6XT6GVXF3REYSXXANCNFSM4K337SZA.

mcollina commented 3 years ago

Closed for no activity, feel free to reopen if you are still interested.