Capture_body is ignored

Hello Elastic Team,

I testing javaAgent and I trying to log "context.request.body" in APM.
Withe these configuration :
elastic.apm.capture_body=transactions
or
elastic.apm.capture_body=all

The context.request.body is alway set to [REDACTED]

Regards,

Chris.

Hi and thanks for trying out the Java agent :slightly_smiling_face:

Which type of body do you want to record? Currently, only application/x-www-form-urlencoded (form parameters) are collected. Technically, for GET requests, form parameters are not transmitted in the body, but rather as query parameters. That's why you won't see them in context.request.body but in context.request.url.full.

Could you enable debug logging to verify that the configuration option was actually read? When starting the application, you can then see what the current configuration is. Example:

2018-07-20 10:47:09.759 [main] INFO co.elastic.apm.configuration.StartupInfo - Starting Elastic APM 0.7.0-SNAPSHOT on Java 1.8.0_162 (Oracle Corporation) Mac OS X 10.13.6
2018-07-20 10:47:09.761 [main] DEBUG co.elastic.apm.configuration.StartupInfo - service_name: 'spring-petclinic' (source: Java System Properties)
2018-07-20 10:47:09.761 [main] DEBUG co.elastic.apm.configuration.StartupInfo - logging.log_level: 'DEBUG' (source: Java System Properties)
2018-07-20 10:47:09.761 [main] DEBUG co.elastic.apm.configuration.StartupInfo - capture_body: 'TRANSACTIONS' (source: Java System Properties)

With this configuration, capturing the body of a post form works for me:

"body": {
  "firstName": "Betty",
  "lastName": "Davis",
  "address": "638 Cardinal Ave.",
  "city": "Sun Prairie",
  "telephone": "6085551749"
}

Hi Felix,

OK I have my answer. I use only multipart/form-data not application/x-www-form-urlencoded.
May be in a futur release :wink:

Chris.

Dealing with multipart data is kind of tricky with the Servlet API. That's why it's not supported yet, but possibly will be in a future release.

I've fixed the documentation: https://www.elastic.co/guide/en/apm/agent/java/master/config-http.html#config-capture-body

Thanks Felix :slight_smile:

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