# Transaction\_sample\_rate post 8 release versions

**URL:** <https://discuss.elastic.co/t/transaction-sample-rate-post-8-release-versions/343290>\
**Category:** Elasticsearch\
**Created:** [September 18, 2023, 6:53pm UTC](https://discuss.elastic.co/t/transaction-sample-rate-post-8-release-versions/343290 "2023-09-18T18:53:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![senyam08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senyam08/32/106230_2.png) [@senyam08](https://discuss.elastic.co/u/senyam08)\
**Post date:** [September 18, 2023, 6:53pm UTC](https://discuss.elastic.co/t/transaction-sample-rate-post-8-release-versions/343290/1 "2023-09-18T18:53:52Z")

</div>

We haev java agent 1.42 and Elasticsearch/APM servers are in 8.10 version.  
I haev tried with sampling rate of .2 and .5. Both values and 1 are getting response time/throughput for all samples. But document has change in behavior post 8 release as below  
Could you check and update how sampling rate works with 8.10 version?

As per documentation  
transaction\_sample\_rate  
By default, the agent will sample every transaction (e.g. request to your service). To reduce overhead and storage requirements, you can set the sample rate to a value between 0.0 and 1.0. (For pre-8.0 servers the agent still records and sends overall time and the result for unsampled transactions, but no context information, labels, or spans. When connecting to 8.0+ servers, the unsampled requests are not sent at all).

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [September 18, 2023, 7:10pm UTC](https://discuss.elastic.co/t/transaction-sample-rate-post-8-release-versions/343290/2 "2023-09-18T19:10:25Z")

</div>

> [@senyam08](#):
>
> When connecting to 8.0+ servers, the unsampled requests are not sent at all).

Hi @senyam08

**Corrected**

What the agent does is they send the effective sampling rate along with sampled trace events, and APM Server extrapolates metrics from that. So for example, say the sampling rate is 0.5. Then for every transaction that APM Server observes, it will count it as 2 (inverse sample rate = 1/0.5).

So say you do `0.1` (BTW include the leading `0` please) and you have 100 Transactions  
10 Will be Sampled with the Complete Context etc.  
For the Other 90 Elastic APM calculate as described above for transaction rate and latency as metrics based on the sample transactions so they can be shown in visualizations, and used alerts, ML jobs etc.

This model works well at scale, but if you have very low transaction rates, you want to make sure that you have a fairly high sample rate.

Hope that helps.

---

<div class="post-metadata">

**Author:** ![senyam08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senyam08/32/106230_2.png) [@senyam08](https://discuss.elastic.co/u/senyam08)\
**Post date:** [September 19, 2023, 2:08am UTC](https://discuss.elastic.co/t/transaction-sample-rate-post-8-release-versions/343290/3 "2023-09-19T02:08:09Z")

</div>

Yes. makes sense. Confused with statement in 8+ version. Could you define what happens to errors and stack traces collection with sampling set? does APM agent collect all errors and its stack-traces? if so, is there anyway to reduce number of errors stack-traces with same type to reduce storage?

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [September 19, 2023, 2:28am UTC](https://discuss.elastic.co/t/transaction-sample-rate-post-8-release-versions/343290/4 "2023-09-19T02:28:29Z")

</div>

@senyam08 all errors/exceptions are kept regardless of the sampling rate. In case you haven't found it yet, there's more documentation on sampling at [Transaction sampling | APM User Guide [8.11] | Elastic](https://www.elastic.co/guide/en/apm/guide/current/sampling.html#head-based-sampling)

> if so, is there anyway to reduce number of errors stack-traces with same type to reduce storage?

Not out of the box. You could write an ingest pipeline that samples error documents (i.e. drops them with some probability), but the tricky part would be working out the right probability. That's not likely to catch rare exceptions though. This might be a job for a [`latest` Transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/transform-overview.html#latest-transform-overview), grouping by the `error.grouping_key` field. That field is based on a hash of the stacktrace, so you can use it to deduplicate exceptions.

---

<div class="post-metadata">

**Author:** ![senyam08](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/senyam08/32/106230_2.png) [@senyam08](https://discuss.elastic.co/u/senyam08)\
**Post date:** [September 19, 2023, 3:10pm UTC](https://discuss.elastic.co/t/transaction-sample-rate-post-8-release-versions/343290/5 "2023-09-19T15:10:40Z")

</div>

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:** [October 17, 2023, 3:10pm UTC](https://discuss.elastic.co/t/transaction-sample-rate-post-8-release-versions/343290/6 "2023-10-17T15:10:56Z")

</div>

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