From 08aeaf6cca585e05a05d367b629d565457d1433e Mon Sep 17 00:00:00 2001 From: Josh Dover Date: Fri, 2 Oct 2020 14:24:18 -0600 Subject: [PATCH] Filter username out of payload --- src/apm.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/apm.js b/src/apm.js index a85e248fffde4..408348265d150 100644 --- a/src/apm.js +++ b/src/apm.js @@ -36,7 +36,18 @@ module.exports = function (serviceName = name) { apmConfig = loadConfiguration(process.argv, ROOT_DIR, isKibanaDistributable); const conf = apmConfig.getConfig(serviceName); - require('elastic-apm-node').start(conf); + const apm = require('elastic-apm-node'); + + // Filter out username PII + apm.addFilter((payload) => { + if (payload.context && payload.context.user && payload.context.user.username) { + delete payload.context.user.username; + } + + return payload; + }); + + apm.start(conf); }; module.exports.getConfig = (serviceName) => {