# Is it possible to record the transaction with sample rate as well, but not all of them?

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-record-the-transaction-with-sample-rate-as-well-but-not-all-of-them/183800>\
**Category:** APM\
**Created:** [June 1, 2019, 2:08am UTC](https://discuss.elastic.co/t/is-it-possible-to-record-the-transaction-with-sample-rate-as-well-but-not-all-of-them/183800 "2019-06-01T02:08:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenshin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kenshin/32/2508_2.png) [@kenshin](https://discuss.elastic.co/u/kenshin)\
**Post date:** [June 1, 2019, 2:08am UTC](https://discuss.elastic.co/t/is-it-possible-to-record-the-transaction-with-sample-rate-as-well-but-not-all-of-them/183800/1 "2019-06-01T02:08:18Z")

</div>

Hi there,

We are trying to use Elastic APM for performance monitoring and tracing. The official document said,

> 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. We still record overall time and the result for unsampled transactions, but no context information, tags, or spans.

We have tested it on our production, based on my rough estimation of our case, if all the unsampled transactions will be recorded, the total QPS is more than 100k, and the data volume in ES is also too expensive.

I'd like to ask if we can just record the things only if it is sampled, not just the spans/tags, but also the root transactions. I understood the cons is we can directly get the number like tpm via Kibana, but most of the features worked well like latency calculation and tracing. But the benefits are so big, we can save the cost and resources. I didn't find the similar configuration from the APM documentation, can anyone help?

Thanks

**Kibana version** : 7.1

**Elasticsearch version** : 7.1

**APM Server version** : 7.1

**APM Agent language and version** : Python/Java/Go

---

<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:** [June 4, 2019, 5:06am UTC](https://discuss.elastic.co/t/is-it-possible-to-record-the-transaction-with-sample-rate-as-well-but-not-all-of-them/183800/2 "2019-06-04T05:06:37Z")

</div>

What you could do is add a `drop_event` processor to apm-server.yml, conditional on `transaction.sampled: false`. You can find more information about processors in the Filebeat docs, but they're relevant to the APM Server too: [https://www.elastic.co/guide/en/beats/filebeat/current/filtering-and-enhancing-data.html](https://www.elastic.co/guide/en/beats/filebeat/current/filtering-and-enhancing-data.html).

Longer term, we're looking into options for both server-side rollups of raw data (giving you the ability to control retention), and agent-side rollups (sending pre-aggregated statistics to APM Server to reduce the ingestion rate in the first place).

---

<div class="post-metadata">

**Author:** ![kenshin](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kenshin/32/2508_2.png) [@kenshin](https://discuss.elastic.co/u/kenshin)\
**Post date:** [June 21, 2019, 6:17pm UTC](https://discuss.elastic.co/t/is-it-possible-to-record-the-transaction-with-sample-rate-as-well-but-not-all-of-them/183800/3 "2019-06-21T18:17:16Z")

</div>

Thanks for the advice, I have tried the drop\_event solution, but it doesn't work. Would you like to help me to check my configuration?

```
apm-server:
  host: 0.0.0.0:8200
output:
  elasticsearch:
    bulk_max_size: 4096
    hosts:
    - my-es
    protocol: http
  file:
    enabled: false
processors:
  drop_event:
    when:
      equals:
        transaction.sampled: false
setup:
  template:
    overwrite: true
    settings:
      index:
        number_of_shards: 5
```

---

<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:** [July 2, 2019, 2:46am UTC](https://discuss.elastic.co/t/is-it-possible-to-record-the-transaction-with-sample-rate-as-well-but-not-all-of-them/183800/4 "2019-07-02T02:46:17Z")

</div>

Sorry for the delay in replying. There's a slight error in your syntax. Processors should be a YAML list; you're missing a "-" before drop\_event. It should look like this:

```bash
processors:
 - drop_event:
     when:
       equals:
         transaction.sampled: false

```

---

<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:** [July 22, 2019, 10:51pm UTC](https://discuss.elastic.co/t/is-it-possible-to-record-the-transaction-with-sample-rate-as-well-but-not-all-of-them/183800/5 "2019-07-22T22:51:21Z")

</div>

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