pino-elasticsearch icon indicating copy to clipboard operation
pino-elasticsearch copied to clipboard

Some log messages are not accepted by the elastic search, but pino-elasticsearch does not show any error or warning

Open euglv opened this issue 5 years ago • 2 comments

For example, if different log objects have fields with the same name but with different value type. If we do:

logger.info({ test: 123 });
logger.info({ test: "string value" }); // this log message will not be added 

Then the last log message will not be added to the elastic search because of the error: failed to parse field [test] of type [long] in document with id ... but pino-elasticsearch will not output any error or warning.

euglv avatar Aug 07 '20 15:08 euglv

@delvedor wdyt?

mcollina avatar Aug 07 '20 15:08 mcollina

If you look at the code, you will see that Pino Elastic returns an EventEmitter:

const pinoElastic = require('pino-elasticsearch');

const streamToElastic = pinoElastic({
  // ...
});

streamToElastic.on('insertError', (error: any) => console.log('ERROR', error));

This will at least let you see what the issue is and bypasses Pino (so it's not aggregated in a loop).

rclayton-godaddy avatar Apr 16 '21 00:04 rclayton-godaddy