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 can I add Datadog to Pino?

See original GitHub issue

[x] I’ve read the docs of nestjs-pino

[x] I’ve read the docs of pino

[x] I couldn’t find the same question about nestjs-pino

How can I add Datadog to nest-js pino?

I tried using pino-datadog-transport package with following options

import { LoggerModule } from 'nestjs-pino';

@Module({
  imports: [
    LoggerModule.forRoot({
        {
          pinoHttp: {
            transport: {
              targets: [
                {
                  options: {
                    ignore: 'pid,hostname',
                    levelFirst: true,
                    translateTime: 'UTC:dd/mm/yyyy, h:MM:ss TT Z',
                  },
                  target: 'pino-pretty',
                  level: 'debug',
                },
                {
                  level: 'debug',
                  target: 'pino-datadog-transport',
                  options: {
                    ddClientConf: {
                      authMethods: {
                        apiKeyAuth: config.DATADOG_API_KEY,
                        ddServerConf: { site: 'datadoghq.eu' },
                        ddSource: 'nodejs',
                        service: config.DATADOG_APP_NAME,
                      },
                    },
                  },
                },
              ],
            },
          },
        };
    })
  ],
  ...
})
class MyModule {}

but it is not working. Please let me know how can I integrate Datadog with Pino in Nestjs with a working example, thank you.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
gitSambhalcommented, Sep 27, 2022

@iamolegga I was able to make it work but there is one issue that the hostname and service name are not showing in Datadog. Screenshot 2022-09-27 at 9 58 35 AM When I used the Winston nestjs package then the service name was showing.

Got it working. It was configuration error in pino-datadog-transport.

  const ddTransportConfigEU: TransportTargetOptions = {
    level,
    options: {
      ddClientConf: {
        authMethods: {
          apiKeyAuth: env.DD_API_KEY,
        },
        ddServerConf: { site: env.DD_SITE },
      },
      ddsource: 'nodejs',
      service: env.DD_SERVICE,
    },
    target: 'pino-datadog-transport',
  };
0reactions
gitSambhalcommented, Sep 27, 2022

@iamolegga I was able to make it work but there is one issue that the hostname and service name are not showing in Datadog. Screenshot 2022-09-27 at 9 58 35 AM When I used the Winston nestjs package then the service name was showing.

Read more comments on GitHub >

github_iconTop Results From Across the Web

pino-datadog - npm
A transport for pino that sends messages to DataDog. Latest version: 2.0.2, last published: 2 years ago. Start using pino-datadog in your ...
Read more >
A transport for pino that sends messages to DataDog - GitHub
A transport for pino that sends messages to DataDog - GitHub - ovhemert/pino-datadog: A transport for pino ... To include as a library...
Read more >
pino-datadog-transport - NPM Package Overview - Socket.dev
A pino v7+ transport for sending logs to Datadog. It uses datadog-api-client-typescript to send logs using the client v2.LogsApi#submitLog ...
Read more >
Make pino Log Messages Appear with the Correct Status in ...
How to correctly display the log level (status) in Datadog when using the pino logger. By default all messages are marked as 'info'-level....
Read more >
Connecting Node.js Logs and Traces - Datadog Docs
Connect your Node.js logs and traces to correlate them in Datadog.
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