-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding filtering to the logger #5038
Conversation
- Closes elastic#5036 - Add `applyFilterToKey()` - Add test for `applyFilterToKey()` - Add `filter` attribute to config for reporters - Add `this.filter` method to `LogFormat` class
dest: config.get('logging.dest') | ||
dest: config.get('logging.dest'), | ||
filter: { | ||
authorization: 'remove' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this just remove the "authorization"
key from every object logged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
|
||
it('should remove an entire branch', function () { | ||
var data = fixture(); | ||
applyFilterToKey(data, 'headers', 'remove'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaks when you use "censor"
.
- Add ability to specify filters from CLI options - Add test and fix for removing branch with censor - Add change regex to use strings
@@ -61,7 +61,7 @@ module.exports = Joi.object({ | |||
|
|||
events: Joi.any().default({}), | |||
dest: Joi.string().default('stdout'), | |||
|
|||
filter: Joi.any().default({}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move the defaults here please? With the current implementation you can't log authorization headers even if you wanted to. Missed the note below
This currently fails when the Since we are only interested in filtering values that will end up in the final output, perhaps we should start |
`applyFilterToKey()` used to choke on circular structures by simply recursing through the object passed in. When we create a circular structure though, we generally provide a simplified version of the object via `obj#toJSON()`. This makes logging those objects simple, and now the filter will use the same mechanism before attempting to itterate the object.
I took a stab at fixing this and sent you a PR simianhacker#6 |
[server/log] simplify the log messages before filtering
return obj; | ||
} | ||
|
||
module.exports = function applyFilterToKey(obj, key, action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems a tad strange to me to have one function exported by module.exports
and one as a property (module.exports. applyFiltersToKeys
). I think personally it would be better to export just applyFiltersToKeys
, seeing as how that's all that is used anyway (besides in the tests), or export both under keys (applyFiltersToKey
and applyFiltersToKeys
).
Other than the comment above, LGTM. |
LGTM. |
Adding filtering to the logger
This was never backported to 4.2 |
applyFilterToKey()
applyFilterToKey()
filter
attribute to config for reportersthis.filter
method toLogFormat
class