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.

Pino Redact does not work with Pino HTTP customAttributeKeys.

See original GitHub issue

I currently am using pino-http to map to an ECS format. When doing so though my redactions are not taking place.

redact: {
    paths: ['http.request.headers.authorization'],
    censor: '***REDACTED***',
  },
  customAttributeKeys: {
    req: 'http.request',
  },

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
batersoncommented, Oct 6, 2022

@sethtomy Your example doesn’t work because pino assumes that it should redact an object with the given structure:
{ http: { request: { headers: { authorization: "" }}}} But in your case it’s:
{ "http.request": { headers: { authorization: "" }}}

So to make it work, you just need to rewrite the path or use a key without dots in name:

redact: {
    paths: ['["http.request"].headers.authorization'],
    censor: '***REDACTED***',
},
customAttributeKeys: {
    req: 'http.request',
},
0reactions
sethtomycommented, Nov 4, 2022

@RohitRox thank you for responding. Unfortunately that does not seem to work in combination with “customAttributeKeys”.

@baterson that works perfectly! If you don’t mind, for my curiosity, I’m interested in how that’s working. A took ~ an hour to look into the issue myself but Streams unfortunately are not my strong suit (I need to learn 😃) How is the dot notation for ‘http.request.headers.authorization’ structurally different from ‘[“http.request”].headers.authorization’. Is there something special around that first “http.request” key?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues · pinojs/pino-http - GitHub
Contribute to pinojs/pino-http development by creating an account on GitHub. ... Pino Redact does not work with Pino HTTP customAttributeKeys.
Read more >
How to redact sensitive information from logs using Pino ...
We pass both the serializers (the pino standard error serializer) and redaction keys (more on this below) to the serializers key. Redacting keys....
Read more >
HTTP Pino logger and Elastic Common Schema (ecs) format ...
The problem I face is now my log contains duplicate the req and the http.request and can't find a way to remove it....
Read more >
How to redact sensitive information from logs using ... - Nikhil
Pino is a very low overhead logger for Node (their documentation claims it is over 5 times faster than alternatives). Here's how to...
Read more >
Top 5 pino-std-serializers Code Examples - Snyk
Learn more about how to use pino-std-serializers, ... Use Snyk Code to scan source code in minutes - no build needed - and...
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