How can i log http response body in apm

(Umapati Singh) #1

my current apm configuration is as follows:

config.apm = {
serviceName: 'MyService',
secretToken: '',
serverUrl: 'localhost:5601',
captureBody: 'all',
instrument: 'true',
errorOnAbortedRequests: 'true'

var apm = require('elastic-apm-node').start({
serviceName: config.apm.serviceName,
secretToken: config.apm.secretToken,
serverUrl: config.apm.serverUrl,
captureBody: config.apm.captureBody,

the http request body is captured correctly. I would like to know if there is an existing way to capture the response too.

(Thomas Watson) #2

Not automatically, but if you have the body in a variable, you can attach it to the transaction manually by calling apm.setCustomContext(), eg:

  responseBody: body

Just remember to call this function before the request have ended.

(system) #3

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.