pinojs/pino-elasticsearch

How to debug implementation as module ? Log not showing in Elasticsearch

cyril94440 opened this issue · 8 comments

Hi there,

I am trying top use this lib as a module but unfortunately logs are not showing in Elasticsearch and I don't have anything displayed in my console related to this module.

Here is my code :

import * as pino from "pino";
import { multistream } from "pino-multi-stream";
const pinoElastic = require("pino-elasticsearch");

const streamToElastic = pinoElastic({
	node: "http://elastic:PASSWORD@URL:9200",
});

var streams = [{ stream: process.stdout }, { stream: streamToElastic }];

export const logger = pino({ level: "debug" }, multistream(streams)).child({ infoAddedToAllLogs: "test" });

logger.debug("Hello world");

Logs are successfully displayed in console, but unfortunately nothing related to Elasticsearch errors and nothing in Elasticsearch.

How can I debug this?

Thanks for your help

Definitely interested in this too. Not seeing any sort of error output.

@cyril94440
can you try to run it with flush-bytes option => flush-bytes: 1

import * as pino from "pino";
import { multistream } from "pino-multi-stream";
const pinoElastic = require("pino-elasticsearch");

const streamToElastic = pinoElastic({
	node: "http://elastic:PASSWORD@URL:9200",
        flush-bytes: 1
});

var streams = [{ stream: process.stdout }, { stream: streamToElastic }];

export const logger = pino({ level: "debug" }, multistream(streams)).child({ infoAddedToAllLogs: "test" });

logger.debug("Hello world");

My assumption is: if the message is too short and the program quits, and the logs do not show up.
I'm trying to debug it right now to see if that is the case.

@frenkelor you are correct and that bit me the other day.

However, when I had firewall rules too restrictive on my Elastic Search host, I could not get any sort of output to show logs were/were not sending to ES - so while flush-bytes may lower the threshold to send logs to Elastic Search, it would still be nice to see logs of when this module can't forward to Elastic Search and why.

it would still be nice to see logs of when this module can't forward to Elastic Search and why.

@kyleratti try this DEBUG=* node app.js, (nothing to do with this package)

Hi,

Is there any update here? I'm experiencing the same issue.

Hello! I've just run this code:

'use strict'

const Pino = require('pino')
const { multistream } = require('pino-multi-stream')
const pinoElastic = require('pino-elasticsearch')

const streamToElastic = pinoElastic({
  node: 'http://localhost:9200',
  index: 'logs',
  'flush-interval': 1000
})

var streams = [{ stream: process.stdout }, { stream: streamToElastic }]

const pino = Pino({ level: 'info' }, multistream(streams)).child({ infoAddedToAllLogs: 'test' })

pino.info('Hello world')

And everything works as expected.
pino-elasticsearch sends the logs if either flush-bytes is reached or if flush-interval has elapsed.
Unless something kills the process before flush-interval is triggered, the process will wait until all timers have been executed.

Be aware that you will not see the logs immediately in Elasticsearch because of the refresh interval.

Hi @delvedor , It works! Thank you