# Question on how to choose the aggregations for ML job

**URL:** <https://discuss.elastic.co/t/question-on-how-to-choose-the-aggregations-for-ml-job/207047>\
**Category:** Kibana\
**Tags:** elastic-stack-machine-learning\
**Created:** [November 8, 2019, 5:32am UTC](https://discuss.elastic.co/t/question-on-how-to-choose-the-aggregations-for-ml-job/207047 "2019-11-08T05:32:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![satyam2593](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@satyam2593](https://discuss.elastic.co/u/satyam2593)\
**Post date:** [November 8, 2019, 5:32am UTC](https://discuss.elastic.co/t/question-on-how-to-choose-the-aggregations-for-ml-job/207047/1 "2019-11-08T05:32:42Z")

</div>

I have the documents which contains the Response codes like 200,400, 500.  
Now i have to create the ML job it should filter the documents which contains the response codes other than 200 treated as Anomalies.  
Below are the fields looks like  
@timestamp Nov 8, 2019 @ 05:21:15.401  
@version 1  
Address [http://xxxxxxxxx/services/api/e](http://xxxxxxxxx/services/api/e)  
Message\_Id 33xxxxx  
Request\_Time Nov 8, 1970 @ 06:21:14.924  
Response-Code 200  
Response\_Payload {"success":true,"message":"Loaded 0 entries","data":,"total":"0","metaData":{"root":"data","fields":  
I have added data feed as  
{  
"bool": {  
"filter": {  
"range": {  
"Response-Code": {  
"gte": "201"  
}  
}  
}  
}  
}

Now what is the detector i have to choose to detect Anomalies

---

<div class="post-metadata">

**Author:** ![richcollier](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/richcollier/32/115035_2.png) [@richcollier](https://discuss.elastic.co/u/richcollier)\
**Post date:** [November 11, 2019, 1:08pm UTC](https://discuss.elastic.co/t/question-on-how-to-choose-the-aggregations-for-ml-job/207047/2 "2019-11-11T13:08:27Z")

</div>

Since you are looking for anomalies in occurrence rates, you need to use the `count` detector.

If you want to count the occurrence rate of every `Response-Code` individually, you would "split" the analysis by using `partition_field_name : Response-Code`

```auto
  "analysis_config": {
    "bucket_span": "15m",
    "detectors": [
      {
        "function": "count",
        "partition_field_name": "Response-Code"
      }
    ],
    "influencers": [
      "Response-Code"
    ]
  },

```

---

<div class="post-metadata">

**Author:** ![satyam2593](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@satyam2593](https://discuss.elastic.co/u/satyam2593)\
**Post date:** [November 12, 2019, 5:12am UTC](https://discuss.elastic.co/t/question-on-how-to-choose-the-aggregations-for-ml-job/207047/3 "2019-11-12T05:12:25Z")

</div>

Thanks for the solution

---

<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:** [December 10, 2019, 5:22am UTC](https://discuss.elastic.co/t/question-on-how-to-choose-the-aggregations-for-ml-job/207047/4 "2019-12-10T05:22:37Z")

</div>

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