#general

Custom Fields in Logger Detail View with NodeJS/Winson

TLDR Harald asked how to add custom fields to the logger detail view using NodeJS/winson. Srikanth provided a user guide link and confirmed that using the opentelemetry instrumentation winston package would help.

Powered by Struct AI

1

Mar 17, 2023 (9 months ago)
Harald
Photo of md5-01b4600434aa419becd17a9f7773e2ff
Harald
05:17 PM
Is there a way in the logger to put custom fields to the detail view? I am using NodeJS/winson (just for fun).
05:17
Harald
05:17 PM
const extra = { extra : { duno: "foo", whatever: "bar" } };

app.listen(port, () => {
  logger.log('info', 'Example app listening at :%d', port, extra);
});
05:18
Harald
05:18 PM
Image 1 for
05:19
Harald
05:19 PM
Is there a way to extract this or let my use it in queries?
05:20
Harald
05:20 PM
in DDog I used to put in here stuff like the batch_id or a customer_id which makes it easy to debug
Srikanth
Photo of md5-ce04a9988e2fd758a659dc55be6f2543
Srikanth
06:03 PM
Yes, that will help for injecting trace context which will help in correlation
Harald
Photo of md5-01b4600434aa419becd17a9f7773e2ff
Harald
06:03 PM
or does this only work, because trace_id, span_id and trace_flags is already part of the collector ?
06:04
Harald
06:04 PM
btw. I have no issue just talking to the collector via IP - metrics already need this hack
Srikanth
Photo of md5-ce04a9988e2fd758a659dc55be6f2543
Srikanth
06:04 PM
As you can see from the description, it is your winston logger + trace context injected.
Harald
Photo of md5-01b4600434aa419becd17a9f7773e2ff
Harald
06:08 PM
I think this just adds the 3 fields to <http://logger.info|logger.info>( ... ok -check-
06:09
Harald
06:09 PM
I go with the userguide you send me 🙂

SigNoz Community

Built with ClickHouse as datastore, SigNoz is an open-source APM to help you find issues in your deployed applications & solve them quickly | Knowledge Base powered by Struct.AI

Indexed 1023 threads (61% resolved)

Join Our Community

Similar Threads

Extracting Custom Fields as Attributes from Log in SigNoz

Harald wants to have custom fields from their body parsed as attributes in the SigNoz logger. They have tried implementing suggestions from nitya-signoz and Prashant, but the issue remains unsolved due to a potential race condition encountered while executing the code. They have provided a full example using Kind for further assistance.

4

209
5mo

Discussing Processor Pipeline and Column Creation for Faster Searching

Shivam inquired about creating trace_id and span_id in processor pipelines and ran into issues. nitya-signoz clarified that trace_id cannot be copied and suggested making fields selected in the explorer page to improve search speed. Shivam understood this solution.

2

21
3mo

Adding Traceid in Logs and Utilizing Helm for SigNoz Installation

Charan sought assistance on adding traceid in logs. nitya-signoz advised how to parse it and Prashant suggested modification of the logtransform processor or addition of a new one as a solution.

13
5mo

Configuring trace_id and span_id Extraction in Node App Logs

Saad was struggling to extract trace_id and span_id from their node app logs and asked for help. nitya-signoz instructed them to add the processor to the services, and this solved the issue.

2

12
1w

Adding Labels to Logs in SigNoz Using Pipelines

Tarek was trying to add labels from a JSON body to SigNoz logs. nitya-signoz and Shivanshu helped by providing pipeline examples and configurations. nitya-signoz's solution eventually resolved the issue.

1

34
3mo