# Stuck on \[Bucket max\] cardinality estimate required for \[influencers\] \[response\_time\_cat\] but not supplied

**URL:** <https://discuss.elastic.co/t/stuck-on-bucket-max-cardinality-estimate-required-for-influencers-response-time-cat-but-not-supplied/315533>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-machine-learning, runtime-fields\
**Created:** [September 30, 2022, 8:42am UTC](https://discuss.elastic.co/t/stuck-on-bucket-max-cardinality-estimate-required-for-influencers-response-time-cat-but-not-supplied/315533 "2022-09-30T08:42:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Souvik\_Das](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/souvik_das/32/107606_2.png) [@Souvik\_Das](https://discuss.elastic.co/u/Souvik_Das)\
**Post date:** [September 30, 2022, 8:42am UTC](https://discuss.elastic.co/t/stuck-on-bucket-max-cardinality-estimate-required-for-influencers-response-time-cat-but-not-supplied/315533/1 "2022-09-30T08:42:33Z")

</div>

Hi team,

I have created a runtime field (categorical field) in the Datafeed of ml job to use it as an influencer for the anomalies. I am able to find the field in the influencer section but after that when I tried to finish the job, getting the below errors one after another --

`[request body.datafeedConfig.fields]: definition for this key is missing`

```auto
{
  "statusCode": 400,
  "error": "Bad Request",
  "message": "illegal_argument_exception",
  "attributes": {
    "body": {
      "error": {
        "root_cause": [
          {
            "type": "illegal_argument_exception",
            "reason": "[Bucket max] cardinality estimate required for [influencers] [response_time_cat] but not supplied"
          }
        ],
        "type": "illegal_argument_exception",
        "reason": "[Bucket max] cardinality estimate required for [influencers] [response_time_cat] but not supplied"
      },
      "status": 400
    }
  }
}

```

See below the datafeed --

```auto
{
  "datafeed_id": "",
  "job_id": "",
  "indices": [
    "xyz"
  ],
  "runtime_mappings": {
    "response_time_cat": {
      "type": "keyword",
      "script": {
        "source": """if (doc['response_time'].value >= 0 && doc['response_time'].value < 30) {emit("low");} 
		else if (doc['response_time'].value >= 31 && doc['response_time'].value < 60) {emit("medium");} 
		else if (doc['response_time'].value >= 61) {emit("high");} 
		else{emit("unknown");}"""
      }
    }
  },
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "match_all": {}
        },
        {
          "match_phrase": {
            "part.keyword": "ABC"
          }
        }
      ],
      "should": [],
      "must_not": []
    }
  },
  "fields": [
    {
      "field": "response_time_cat"
    }
  ],
  "query_delay": "120s"
}

```

ELK version 7.11.1  
Please help me to resolve the issue.

Regards.  
Souvik

---

<div class="post-metadata">

**Author:** ![sophie\_chang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sophie_chang/32/18008_2.png) [@sophie\_chang](https://discuss.elastic.co/u/sophie_chang)\
**Post date:** [September 30, 2022, 10:46am UTC](https://discuss.elastic.co/t/stuck-on-bucket-max-cardinality-estimate-required-for-influencers-response-time-cat-but-not-supplied/315533/2 "2022-09-30T10:46:15Z")

</div>

Are you using the UI or APIs (e.g. in DevTools) to create the job?  
Please also include the job config.  
Could you see anything via the preview tab?

---

<div class="post-metadata">

**Author:** ![Souvik\_Das](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/souvik_das/32/107606_2.png) [@Souvik\_Das](https://discuss.elastic.co/u/Souvik_Das)\
**Post date:** [September 30, 2022, 11:07am UTC](https://discuss.elastic.co/t/stuck-on-bucket-max-cardinality-estimate-required-for-influencers-response-time-cat-but-not-supplied/315533/3 "2022-09-30T11:07:25Z")

</div>

Hi @sophie_chang ,

Thanks for your quick response.

I have used "Advanced Configuration Wizard" for this purpose. Also seen the output of the datafeed in the preview window. See below --

![image](https://us1.discourse-cdn.com/elastic/original/3X/e/4/e453726f14e36c49a22c5edffc423a2f026eab8f.png)

See below the job config --

```auto
{
  "job_id": "test_and_delete_runtime_field_added",
  "description": "",
  "groups": [],
  "analysis_config": {
    "bucket_span": "4h",
    "detectors": [
      {
        "function": "low_count"
      }
    ],
    "influencers": [
      "response_time_cat"
    ]
  },
  "data_description": {
    "time_field": "response_datetime"
  },
  "analysis_limits": {
    "model_memory_limit": "10MB"
  },
  "model_plot_config": {
    "enabled": true,
    "annotations_enabled": true
  }
}

```

Am I missing something while configuring?

---

<div class="post-metadata">

**Author:** ![sophie\_chang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sophie_chang/32/18008_2.png) [@sophie\_chang](https://discuss.elastic.co/u/sophie_chang)\
**Post date:** [September 30, 2022, 5:22pm UTC](https://discuss.elastic.co/t/stuck-on-bucket-max-cardinality-estimate-required-for-influencers-response-time-cat-but-not-supplied/315533/4 "2022-09-30T17:22:39Z")

</div>

For your use case, I would expect you would get better results by analysing the average `response_time` ..

The analysis you are doing now will detect low event rate of docs (`low_count`) - although I do not know the shape of your data, it seems more likely that the value of `response_time` is an indicator of slow responses, rather than the event rate of documents. Just a thought.

Putting that aside, it appears that the adv wizard is failing at the validation step. Unfortunately this maybe a bug in the UI as you are using quite an old version.

To workaround the UI validations (without upgrading) I recommend that you create the job using Dev Tools. The following creates the job without errors in 8.4 but may need adjusting for 7.11.1

```auto
PUT _ml/anomaly_detectors/test_and_delete_runtime_field_added
{
  "description": "",
  "groups": [],
  "analysis_config": {
    "bucket_span": "4h",
    "detectors": [
      {
        "function": "low_count"
      }
    ],
    "influencers": [
      "response_time_cat"
    ]
  },
  "data_description": {
    "time_field": "response_datetime"
  },
  "analysis_limits": {
    "model_memory_limit": "10MB"
  },
  "model_plot_config": {
    "enabled": true,
    "annotations_enabled": true
  }
}

PUT _ml/datafeeds/datafeed-test_and_delete_runtime_field_added
{
  "job_id": "test_and_delete_runtime_field_added",
  "indices": [
    "xyz"
  ],
  "runtime_mappings": {
    "response_time_cat": {
      "type": "keyword",
      "script": {
        "source": """if (doc['response_time'].value >= 0 && doc['response_time'].value < 30) {emit("low");} 
		else if (doc['response_time'].value >= 31 && doc['response_time'].value < 60) {emit("medium");} 
		else if (doc['response_time'].value >= 61) {emit("high");} 
		else{emit("unknown");}"""
      }
    }
  },
  "query": {
    "bool": {
      "must": [],
      "filter": [
        {
          "match_all": {}
        },
        {
          "match_phrase": {
            "part.keyword": "ABC"
          }
        }
      ]
    }
  },
  "query_delay": "120s"
}

```

---

<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 28, 2022, 5:23pm UTC](https://discuss.elastic.co/t/stuck-on-bucket-max-cardinality-estimate-required-for-influencers-response-time-cat-but-not-supplied/315533/5 "2022-10-28T17:23:23Z")

</div>

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