hapijs / good

hapi process monitoring
Other
525 stars 160 forks source link

Adding extra fields to top level of log object #570

Closed rossanthony closed 6 years ago

rossanthony commented 6 years ago

We are using 'good' with 'good-squeeze' and 'SafeJson' for logging and the stdout is being consumed by a logging service called Splunk. We have lots of apps and want to be able to easily filter by an AppID.

Is it possible to add a custom field via the config of 'good' or maybe 'good-squeeze', so we can insert a static app identifier to the top level of every object logged by good?

For example:


{ 
   appId: 2001,
   event: "request",
   method: "post",
   path: "/test",
   timestamp: 1510788236049,
   ....
}
arb commented 6 years ago

You'd have to add another transform stream before SafeJson and attach the value there.

rossanthony commented 6 years ago

Thanks @arb, I suspected that might be the only option. Do you know of any good examples showing how to setup a custom transform stream?

arb commented 6 years ago

The tests for good would be a good place to start. Not sure outside of that as people seem to create custom transform streams at the application level and not open source.

rossanthony commented 6 years ago

Looked at the source for 'good-console' that served as a good starting point. Thanks a lot for your help.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.