Create filters API

Create filters API

New API reference

For the most up-to-date API details, refer to Machine learning anomaly detection APIs.

Instantiates a filter.

Request

PUT _ml/filters/<filter_id>

Prerequisites

Requires the manage_ml cluster privilege. This privilege is included in the machine_learning_admin built-in role.

Description

A filter contains a list of strings. It can be used by one or more jobs. Specifically, filters are referenced in the custom_rules property of detector configuration objects. For more information, see Custom rules.

Path parameters

<filter_id>

(Required, string) A string that uniquely identifies a filter.

Request body

description

(Optional, string) A description of the filter.

items

(Required, array of strings) The items of the filter. A wildcard * can be used at the beginning or the end of an item. Up to 10000 items are allowed in each filter.

Examples

  1. resp = client.ml.put_filter(
  2. filter_id="safe_domains",
  3. description="A list of safe domains",
  4. items=[
  5. "*.google.com",
  6. "wikipedia.org"
  7. ],
  8. )
  9. print(resp)
  1. response = client.ml.put_filter(
  2. filter_id: 'safe_domains',
  3. body: {
  4. description: 'A list of safe domains',
  5. items: [
  6. '*.google.com',
  7. 'wikipedia.org'
  8. ]
  9. }
  10. )
  11. puts response
  1. const response = await client.ml.putFilter({
  2. filter_id: "safe_domains",
  3. description: "A list of safe domains",
  4. items: ["*.google.com", "wikipedia.org"],
  5. });
  6. console.log(response);
  1. PUT _ml/filters/safe_domains
  2. {
  3. "description": "A list of safe domains",
  4. "items": ["*.google.com", "wikipedia.org"]
  5. }

When the filter is created, you receive the following response:

  1. {
  2. "filter_id": "safe_domains",
  3. "description": "A list of safe domains",
  4. "items": ["*.google.com", "wikipedia.org"]
  5. }