question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
delvedorcommented, Apr 9, 2021

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.

0reactions
redfajardocommented, Apr 12, 2021

Hi @delvedor , It works! Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

No logs appearing in Kibana - Elasticsearch
I'd first off check if there's the data you expect in Elasticsearch by seeing what indices exist using the API: _cat/indices?v . If...
Read more >
Logging | Elasticsearch Guide [8.5]
Each logger accepts Log4j 2's built-in log levels, from least to most verbose: OFF , FATAL , ERROR , WARN , INFO ,...
Read more >
Elasticsearch Logging Secrets
Another trick that I found myself using several times to debug Groovy scripts in Elasticsearch is logging inside the script itself to double ......
Read more >
Reporting troubleshooting | Kibana Guide [8.5]
When Kibana is running, navigate to the Report Listing page, and click Run ... traffic will be logged via the debug module under...
Read more >
Enable audit logging | Elasticsearch Guide [8.5]
Audit logs are disabled by default. You must explicitly enable audit logging. Audit logs are only available on certain subscription levels. For more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found