# \[APM AGENT\]\[JAVA\] HTTP body size

**URL:** <https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698>\
**Category:** APM\
**Tags:** java\
**Created:** [July 29, 2019, 12:53pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698 "2019-07-29T12:53:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ea1987](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ea1987/32/51356_2.png) [@ea1987](https://discuss.elastic.co/u/ea1987)\
**Post date:** [July 29, 2019, 12:53pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/1 "2019-07-29T12:53:48Z")

</div>

Hi guys,  
I noticed that body saved inside http.request.body.original field has been trunkated. Are there some options to manage this field size?  
Thanks,

Andrea

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 29, 2019, 1:10pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/2 "2019-07-29T13:10:12Z")

</div>

Not yet, but we have discussed adding a configuration option for that. Currently it's capped at 10k chars. Could you elaborate a bit on your use case?

---

<div class="post-metadata">

**Author:** ![ea1987](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ea1987/32/51356_2.png) [@ea1987](https://discuss.elastic.co/u/ea1987)\
**Post date:** [July 29, 2019, 1:22pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/3 "2019-07-29T13:22:18Z")

</div>

I noticed that is set to 10k and it's not due to Elasticsearch (I thought about ignore\_above field property). I set apm to stdout and the original message was already trunkated.  
What you mean on elaborate? Unfortunately payloads are related to some "out of the box" products and refer to order management process, so they are full of data. Is there a way to increase the size? Or do you have any other suggestion? Maybe a way to trunk white spaces indentation?  
Thank you Felix

---

<div class="post-metadata">

**Author:** ![ea1987](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ea1987/32/51356_2.png) [@ea1987](https://discuss.elastic.co/u/ea1987)\
**Post date:** [July 29, 2019, 1:29pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/4 "2019-07-29T13:29:59Z")

</div>

I asked for some info. The order management product original payload size is almost 800k per item. Consider that this product can managet max 10 items per product. So the payload will be 800k X 10.

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 29, 2019, 2:39pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/5 "2019-07-29T14:39:05Z")

</div>

Note that depending on the throughput, this can add significant overhead to record, transmit and store such large request bodies. That's why our agents truncate after 10 000 characters. Is that not a concern in your scenario?

> [@ea1987](#):
>
> What you mean on elaborate?

If you can/want to talk about it I'd be interested in: Why do you want to store the request bodies? Are you doing some kind of processing/analytics on the bodies? What are you trying to achieve with storing them? Could you use the [public API](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html) to add only specific labels, like the product IDs to the transactions?

---

<div class="post-metadata">

**Author:** ![ea1987](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ea1987/32/51356_2.png) [@ea1987](https://discuss.elastic.co/u/ea1987)\
**Post date:** [July 29, 2019, 3:25pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/6 "2019-07-29T15:25:26Z")

</div>

> Blockquote Note that depending on the throughput, this can add significant overhead to record, transmit and store such large request bodies. That's why our agents truncate after 10 000 characters. Is that not a concern in your scenario?

Yes it is. Of course I considered all those facts 🙂 I would like to know if it's possible, anyway. Right now we are saving payload requests on an Oracle DB.  
Brief explaination  
Why do you want to store the request bodies -\> we are developing a Fullfillment Order Management (FOM) platform which interacts with different softwares. That's why it's better to store request bodies.  
Use case -\> log management

> [@felixbarny](#):
>
> Could you use the [public API](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html) to add only specific labels, like the product IDs to the transactions

Can you please explain better this part? Thanks!

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [July 30, 2019, 12:54pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/7 "2019-07-30T12:54:02Z")

</div>

> [@ea1987](#):
>
> we are developing a Fullfillment Order Management (FOM) platform which interacts with different softwares. That's why it's better to store request bodies.

What are you doing with the stored bodies? Are you interested in only specific attributes like the number of items in the cart? If so, you could use the public API to programmatically add custom labels: [Public API | APM Java Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html#api-transaction-add-tag) to the transaction.

Adding this is a bit of a dangerous feature as it's easy to shoot yourself in the foot and might even be used by malicious users to overwhelm your system. That's why I'm a bit hesitant on this. But if it's an opt-in feature and there's an appropriate warning in the documentation, I guess we can add that. Would you be interested in doing a PR for this?

---

<div class="post-metadata">

**Author:** ![Wolfram\_Haussig](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wolfram_haussig/32/70528_2.png) [@Wolfram\_Haussig](https://discuss.elastic.co/u/Wolfram_Haussig)\
**Post date:** [July 31, 2019, 6:48am UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/8 "2019-07-31T06:48:02Z")

</div>

I would like the ability to store larger request bodies too. We have webservice where the typical request is about 1MB and which is called approx. 300 times a day. In case the call fails we would like to store the request so we can re-execute the call. We would not have to store them as long as the rest of the APM data - 3 days should be fine for us.

As APM already creates multiple indexes(for spans, transactions,...) - maybe it is possible that the requests are also stored separately so we could delete those indexes sooner than the rest.

Another thought on this: Currently, the apm agent stores the request(or not) only based on the configuration settings. Maybe it is possible to provide either a method so the application can manually set the request data so the application has control whether the request should be stored or not. This would greatly reduce the fear of malicious usage as the application could validate the request. I do not mean that the application would validate the request for logical correctness as we want to find the errors of requests too of course - I mean that the application could stop the agent to store requests of unauthorized users or requests larger than a plausibility limit or such things.

---

<div class="post-metadata">

**Author:** ![ea1987](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ea1987/32/51356_2.png) [@ea1987](https://discuss.elastic.co/u/ea1987)\
**Post date:** [August 5, 2019, 3:42pm UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/9 "2019-08-05T15:42:50Z")

</div>

Stored bodies are useful if they need to be checked in order to verify/control their consistency through the FOM (consider that more than 8 different products are used and integrated through the business process). We are definetely interested in preserving them.  
Right now I'm trying to create custom transaction (for other purposes) but I'm facing some issues. I will open another thread to keep things separated.  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [August 26, 2019, 11:42am UTC](https://discuss.elastic.co/t/apm-agent-java-http-body-size/192698/10 "2019-08-26T11:42:53Z")

</div>

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