Streamlining Pino Logs to OpenObserve using Node.js

TLDR baris wanted to stream Pino logs from a Node.js app to OpenObserve. With guidance from Ashish, they implemented 'pino-elasticsearch', successfully resolving the issue.

Photo of baris
baris
Mon, 02 Oct 2023 09:22:58 UTC

Hello everyone, In my nodejs application, I want the information I log with pino to be moved to openobserve. I used it as below but the logs do not appear on open observe. How can I do this? ```const sdk = new NodeSDK({ // traceExporter: new opentelemetry.tracing.ConsoleSpanExporter(), traceExporter: new OTLPTraceExporter({ url: "", headers: { Authorization: "Basic a", }, }), instrumentations: [getNodeAutoInstrumentations()], serviceName: "nodejs-javascript-service", });```

Photo of Ashish
Ashish
Mon, 02 Oct 2023 09:29:05 UTC

do you see any error?

Photo of Ashish
Ashish
Mon, 02 Oct 2023 09:29:22 UTC

if not..please go to traces menu

Photo of Ashish
Ashish
Mon, 02 Oct 2023 09:30:06 UTC

and check traces …also remove `duration>1000` from query filter

Photo of Ashish
Ashish
Mon, 02 Oct 2023 09:30:14 UTC

you should be able to see traces

Photo of baris
baris
Mon, 02 Oct 2023 09:37:55 UTC

Ashish Unfortunately, there are no results

Photo of baris
baris
Mon, 02 Oct 2023 09:39:29 UTC

There are file system logs in traces. But I want the ones through pino

Photo of Ashish
Ashish
Mon, 02 Oct 2023 09:40:38 UTC

do you see any error on nodejs app side

Photo of Ashish
Ashish
Mon, 02 Oct 2023 09:40:39 UTC

?

Photo of baris
baris
Mon, 02 Oct 2023 09:41:12 UTC

No it is working

Photo of baris
baris
Mon, 02 Oct 2023 09:41:41 UTC

Photo of Ashish
Ashish
Mon, 02 Oct 2023 10:00:28 UTC

checking

Photo of baris
baris
Mon, 02 Oct 2023 11:23:43 UTC

Photo of baris
baris
Mon, 02 Oct 2023 11:24:01 UTC

Actually, I think it might be useful to be able to use it.

Photo of Ashish
Ashish
Mon, 02 Oct 2023 12:02:01 UTC

I tried that

Photo of Ashish
Ashish
Mon, 02 Oct 2023 12:02:36 UTC

but unless we add event to span..logs are not available as events

Photo of baris
baris
Mon, 02 Oct 2023 12:29:26 UTC

so how can I move the logs of my application to openobserve. I use Pino, there is no file

Photo of Ashish
Ashish
Mon, 02 Oct 2023 12:30:11 UTC

for me to be on same page with you…you want to send Pino logs to logs streams & not to traces as events

Photo of Ashish
Ashish
Mon, 02 Oct 2023 12:30:35 UTC

or you want to see logs as events in traces

Photo of baris
baris
Mon, 02 Oct 2023 12:31:30 UTC

ı want to send pino logs to logs stream

Photo of baris
baris
Mon, 02 Oct 2023 12:34:26 UTC

here is a document for winston logs for signoz

Photo of baris
baris
Mon, 02 Oct 2023 12:34:43 UTC

I want to do something similar to this

Photo of Ashish
Ashish
Mon, 02 Oct 2023 12:34:50 UTC

let me try with Pino for OpenObserve

Photo of Ashish
Ashish
Mon, 02 Oct 2023 13:07:00 UTC

can you try

Photo of baris
baris
Mon, 02 Oct 2023 13:18:06 UTC

thank you Ashish . Does this work with open observe?

Photo of Ashish
Ashish
Mon, 02 Oct 2023 13:34:11 UTC

```const pino = require('pino') const pinoElastic = require('pino-elasticsearch') const streamToElastic = pinoElastic({ index: 'Stream Name', node: '<org_id>/', esVersion: 7, flushBytes: 1000, auth: { username: 'user_name', password: 'pwd' }, }) const logger = pino({ level: 'info' }, streamToElastic)```

Photo of Ashish
Ashish
Mon, 02 Oct 2023 13:34:18 UTC

this works

Photo of baris
baris
Mon, 02 Oct 2023 13:52:56 UTC

is it working on self hosted version?

Photo of Ashish
Ashish
Mon, 02 Oct 2023 13:55:07 UTC

yes

Photo of baris
baris
Mon, 02 Oct 2023 13:56:33 UTC

Thank you very much. it works as I want.

Photo of baris
baris
Mon, 02 Oct 2023 13:56:57 UTC

Ashish :tada: