---
setup:
- skip:
    features:
    - "headers"
    - "allowed_warnings_regex"
---
Test by field:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"by_field_name\"\
        : \"airline\"}]\n  },\n  \"overall_cardinality\": {\n    \"airline\": 50000\n\
        \  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "1573mb"
---
Test by field also influencer:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"by_field_name\"\
        : \"airline\"}],\n    \"influencers\": [ \"airline\" ]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 50000\n  },\n  \"max_bucket_cardinality\": {\n    \"\
        airline\": 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "1573mb"
---
Test by field with independent influencer:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"by_field_name\"\
        : \"airline\"}],\n    \"influencers\": [ \"country\" ]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 50000\n  },\n  \"max_bucket_cardinality\": {\n    \"\
        country\": 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "1578mb"
---
Test over field:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"over_field_name\"\
        : \"airline\"}]\n  },\n  \"overall_cardinality\": {\n    \"airline\": 50000\n\
        \  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "47mb"
---
Test over field also influencer:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"over_field_name\"\
        : \"airline\"}],\n    \"influencers\": [ \"airline\" ]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 50000\n  },\n  \"max_bucket_cardinality\": {\n    \"\
        airline\": 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "47mb"
---
Test over field with independent influencer:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"over_field_name\"\
        : \"airline\"}],\n    \"influencers\": [ \"country\" ]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 50000\n  },\n  \"max_bucket_cardinality\": {\n    \"\
        country\": 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "52mb"
---
Test partition field:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"partition_field_name\"\
        : \"airline\"}]\n  },\n  \"overall_cardinality\": {\n    \"airline\": 50000\n\
        \  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "2354mb"
---
Test partition field also influencer:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"partition_field_name\"\
        : \"airline\"}],\n    \"influencers\": [ \"airline\" ]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 50000\n  },\n  \"max_bucket_cardinality\": {\n    \"\
        airline\": 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "2354mb"
---
Test partition field with independent influencer:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"partition_field_name\"\
        : \"airline\"}],\n    \"influencers\": [ \"country\" ]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 50000\n  },\n  \"max_bucket_cardinality\": {\n    \"\
        country\": 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "2359mb"
---
Test by and partition field:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"by_field_name\"\
        : \"airline\", \"partition_field_name\": \"country\"}]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 4000,\n    \"country\": 600\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "3189mb"
---
Test by and partition fields also influencers:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"by_field_name\"\
        : \"airline\", \"partition_field_name\": \"country\"}],\n    \"influencers\"\
        : [ \"airline\", \"country\" ]\n  },\n  \"overall_cardinality\": {\n    \"\
        airline\": 4000,\n    \"country\": 600\n  },\n  \"max_bucket_cardinality\"\
        : {\n    \"airline\": 60,\n    \"country\": 40\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "3189mb"
---
Test by and partition fields with independent influencer:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"by_field_name\"\
        : \"airline\", \"partition_field_name\": \"country\"}],\n    \"influencers\"\
        : [ \"src_ip\" ]\n  },\n  \"overall_cardinality\": {\n    \"airline\": 4000,\n\
        \    \"country\": 600\n  },\n  \"max_bucket_cardinality\": {\n    \"src_ip\"\
        : 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "3194mb"
---
Test over and partition field:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"over_field_name\"\
        : \"airline\", \"partition_field_name\": \"country\"}]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 4000,\n    \"country\": 600\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "113mb"
---
Test over and partition fields also influencers:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"over_field_name\"\
        : \"airline\", \"partition_field_name\": \"country\"}],\n    \"influencers\"\
        : [ \"airline\", \"country\" ]\n  },\n  \"overall_cardinality\": {\n    \"\
        airline\": 4000,\n    \"country\": 600\n  },\n  \"max_bucket_cardinality\"\
        : {\n    \"airline\": 60,\n    \"country\": 40\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "113mb"
---
Test over and partition fields with independent influencer:
- do:
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"over_field_name\"\
        : \"airline\", \"partition_field_name\": \"country\"}],\n    \"influencers\"\
        : [ \"src_ip\" ]\n  },\n  \"overall_cardinality\": {\n    \"airline\": 4000,\n\
        \    \"country\": 600\n  },\n  \"max_bucket_cardinality\": {\n    \"src_ip\"\
        : 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
- match:
    model_memory_estimate: "118mb"
---
Test missing overall cardinality:
- do:
    catch: "/\\[Overall\\] cardinality estimate required for \\[by_field_name\\] \\\
      [airline\\] but not supplied/"
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"by_field_name\"\
        : \"airline\"}]\n  },\n  \"overall_cardinality\": {\n    \"wrong\": 50000\n\
        \  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
---
Test missing max bucket cardinality:
- do:
    catch: "/\\[Bucket max\\] cardinality estimate required for \\[influencers\\]\
      \ \\[country\\] but not supplied/"
    ml.estimate_model_memory:
      body: "{\n  \"analysis_config\": {\n    \"bucket_span\": \"15m\",\n    \"detectors\"\
        : [{\"function\": \"max\", \"field_name\": \"responsetime\", \"by_field_name\"\
        : \"airline\"}],\n    \"influencers\": [ \"country\" ]\n  },\n  \"overall_cardinality\"\
        : {\n    \"airline\": 50000\n  },\n  \"max_bucket_cardinality\": {\n    \"\
        wrong\": 500\n  }\n}\n"
    headers:
      Content-Type: "application/vnd.elasticsearch+json;compatible-with=8"
      Accept: "application/vnd.elasticsearch+json;compatible-with=8"
    allowed_warnings_regex:
    - ".*rollup functionality will be removed in Elasticsearch.*"
    - "Index \\[\\.profiling-.*\\] name begins with a dot.* and will not be allowed\
      \ in a future Elasticsearch version."
    - "Parameter \\[default_metric\\] is deprecated and will be removed in a future\
      \ version"
