# Machine Learning (Anomaly Detection) Random Sampling Support

**URL:** <https://discuss.elastic.co/t/machine-learning-anomaly-detection-random-sampling-support/323158>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning\
**Created:** [January 13, 2023, 8:17pm UTC](https://discuss.elastic.co/t/machine-learning-anomaly-detection-random-sampling-support/323158 "2023-01-13T20:17:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![BenB196](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benb196/32/83401_2.png) [@BenB196](https://discuss.elastic.co/u/BenB196)\
**Post date:** [January 13, 2023, 8:17pm UTC](https://discuss.elastic.co/t/machine-learning-anomaly-detection-random-sampling-support/323158/1 "2023-01-13T20:17:41Z")

</div>

Hi All,

I was wondering if anyone knows if/how to use [random sampling](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-random-sampler-aggregation.html) with machine learning [anomaly detection](https://www.elastic.co/guide/en/machine-learning/current/ml-ad-overview.html)?

**Use Case**

I would like to monitor data rates sent by various agents to various indices/data streams and would like to know when the data rate is abnormally low. While I know I can use the [low\_count](https://www.elastic.co/guide/en/machine-learning/current/ml-count-functions.html#ml-count) function for this. My concern is the high cardinality I'm looking to monitor against. I was thinking that rather than using a count against all documents, I'd use random sampling to only get a sub-count for each category. My thinking is that whether I look at 10% or 100% of the documents, the relative "rate" of documents would be the same, so looking at them all isn't 100% necessary.

---

<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:** [February 10, 2023, 8:17pm UTC](https://discuss.elastic.co/t/machine-learning-anomaly-detection-random-sampling-support/323158/2 "2023-02-10T20:17:59Z")

</div>

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