1. Packages
  2. Opensearch Provider
  3. API Docs
  4. AnomalyDetection
opensearch 2.3.1 published on Monday, Apr 14, 2025 by opensearch-project

opensearch.AnomalyDetection

Explore with Pulumi AI

opensearch logo
opensearch 2.3.1 published on Monday, Apr 14, 2025 by opensearch-project

    Provides an OpenSearch anonaly detection. Please refer to the OpenSearch anomaly detection documentation for details.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as opensearch from "@pulumi/opensearch";
    
    const foo = new opensearch.AnomalyDetection("foo", {body: `{
      "name": "foo",
      "description": "Test detector",
      "time_field": "@timestamp",
      "indices": [
        "security-auditlog*"
      ],
      "feature_attributes": [
        {
          "feature_name": "test",
          "feature_enabled": true,
          "aggregation_query": {
            "test": {
              "value_count": {
                "field": "audit_category.keyword"
              }
            }
          }
        }
      ],
      "filter_query": {
        "bool": {
          "filter": [
            {
              "range": {
                "value": {
                  "gt": 1
                }
              }
            }
          ],
          "adjust_pure_negative": true,
          "boost": 1
        }
      },
      "detection_interval": {
        "period": {
          "interval": 1,
          "unit": "Minutes"
        }
      },
      "window_delay": {
        "period": {
          "interval": 1,
          "unit": "Minutes"
        }
      },
      "result_index" : "opensearch-ad-plugin-result-test"
    }
    
    `});
    
    import pulumi
    import pulumi_opensearch as opensearch
    
    foo = opensearch.AnomalyDetection("foo", body="""{
      "name": "foo",
      "description": "Test detector",
      "time_field": "@timestamp",
      "indices": [
        "security-auditlog*"
      ],
      "feature_attributes": [
        {
          "feature_name": "test",
          "feature_enabled": true,
          "aggregation_query": {
            "test": {
              "value_count": {
                "field": "audit_category.keyword"
              }
            }
          }
        }
      ],
      "filter_query": {
        "bool": {
          "filter": [
            {
              "range": {
                "value": {
                  "gt": 1
                }
              }
            }
          ],
          "adjust_pure_negative": true,
          "boost": 1
        }
      },
      "detection_interval": {
        "period": {
          "interval": 1,
          "unit": "Minutes"
        }
      },
      "window_delay": {
        "period": {
          "interval": 1,
          "unit": "Minutes"
        }
      },
      "result_index" : "opensearch-ad-plugin-result-test"
    }
    
    """)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/opensearch/v2/opensearch"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := opensearch.NewAnomalyDetection(ctx, "foo", &opensearch.AnomalyDetectionArgs{
    			Body: pulumi.String(`{
      "name": "foo",
      "description": "Test detector",
      "time_field": "@timestamp",
      "indices": [
        "security-auditlog*"
      ],
      "feature_attributes": [
        {
          "feature_name": "test",
          "feature_enabled": true,
          "aggregation_query": {
            "test": {
              "value_count": {
                "field": "audit_category.keyword"
              }
            }
          }
        }
      ],
      "filter_query": {
        "bool": {
          "filter": [
            {
              "range": {
                "value": {
                  "gt": 1
                }
              }
            }
          ],
          "adjust_pure_negative": true,
          "boost": 1
        }
      },
      "detection_interval": {
        "period": {
          "interval": 1,
          "unit": "Minutes"
        }
      },
      "window_delay": {
        "period": {
          "interval": 1,
          "unit": "Minutes"
        }
      },
      "result_index" : "opensearch-ad-plugin-result-test"
    }
    
    `),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Opensearch = Pulumi.Opensearch;
    
    return await Deployment.RunAsync(() => 
    {
        var foo = new Opensearch.AnomalyDetection("foo", new()
        {
            Body = @"{
      ""name"": ""foo"",
      ""description"": ""Test detector"",
      ""time_field"": ""@timestamp"",
      ""indices"": [
        ""security-auditlog*""
      ],
      ""feature_attributes"": [
        {
          ""feature_name"": ""test"",
          ""feature_enabled"": true,
          ""aggregation_query"": {
            ""test"": {
              ""value_count"": {
                ""field"": ""audit_category.keyword""
              }
            }
          }
        }
      ],
      ""filter_query"": {
        ""bool"": {
          ""filter"": [
            {
              ""range"": {
                ""value"": {
                  ""gt"": 1
                }
              }
            }
          ],
          ""adjust_pure_negative"": true,
          ""boost"": 1
        }
      },
      ""detection_interval"": {
        ""period"": {
          ""interval"": 1,
          ""unit"": ""Minutes""
        }
      },
      ""window_delay"": {
        ""period"": {
          ""interval"": 1,
          ""unit"": ""Minutes""
        }
      },
      ""result_index"" : ""opensearch-ad-plugin-result-test""
    }
    
    ",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.opensearch.AnomalyDetection;
    import com.pulumi.opensearch.AnomalyDetectionArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var foo = new AnomalyDetection("foo", AnomalyDetectionArgs.builder()
                .body("""
    {
      "name": "foo",
      "description": "Test detector",
      "time_field": "@timestamp",
      "indices": [
        "security-auditlog*"
      ],
      "feature_attributes": [
        {
          "feature_name": "test",
          "feature_enabled": true,
          "aggregation_query": {
            "test": {
              "value_count": {
                "field": "audit_category.keyword"
              }
            }
          }
        }
      ],
      "filter_query": {
        "bool": {
          "filter": [
            {
              "range": {
                "value": {
                  "gt": 1
                }
              }
            }
          ],
          "adjust_pure_negative": true,
          "boost": 1
        }
      },
      "detection_interval": {
        "period": {
          "interval": 1,
          "unit": "Minutes"
        }
      },
      "window_delay": {
        "period": {
          "interval": 1,
          "unit": "Minutes"
        }
      },
      "result_index" : "opensearch-ad-plugin-result-test"
    }
    
                """)
                .build());
    
        }
    }
    
    resources:
      foo:
        type: opensearch:AnomalyDetection
        properties:
          body: |+
            {
              "name": "foo",
              "description": "Test detector",
              "time_field": "@timestamp",
              "indices": [
                "security-auditlog*"
              ],
              "feature_attributes": [
                {
                  "feature_name": "test",
                  "feature_enabled": true,
                  "aggregation_query": {
                    "test": {
                      "value_count": {
                        "field": "audit_category.keyword"
                      }
                    }
                  }
                }
              ],
              "filter_query": {
                "bool": {
                  "filter": [
                    {
                      "range": {
                        "value": {
                          "gt": 1
                        }
                      }
                    }
                  ],
                  "adjust_pure_negative": true,
                  "boost": 1
                }
              },
              "detection_interval": {
                "period": {
                  "interval": 1,
                  "unit": "Minutes"
                }
              },
              "window_delay": {
                "period": {
                  "interval": 1,
                  "unit": "Minutes"
                }
              },
              "result_index" : "opensearch-ad-plugin-result-test"
            }        
    

    Create AnomalyDetection Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new AnomalyDetection(name: string, args: AnomalyDetectionArgs, opts?: CustomResourceOptions);
    @overload
    def AnomalyDetection(resource_name: str,
                         args: AnomalyDetectionArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def AnomalyDetection(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         body: Optional[str] = None,
                         anomaly_detection_id: Optional[str] = None)
    func NewAnomalyDetection(ctx *Context, name string, args AnomalyDetectionArgs, opts ...ResourceOption) (*AnomalyDetection, error)
    public AnomalyDetection(string name, AnomalyDetectionArgs args, CustomResourceOptions? opts = null)
    public AnomalyDetection(String name, AnomalyDetectionArgs args)
    public AnomalyDetection(String name, AnomalyDetectionArgs args, CustomResourceOptions options)
    
    type: opensearch:AnomalyDetection
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args AnomalyDetectionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args AnomalyDetectionArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args AnomalyDetectionArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AnomalyDetectionArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AnomalyDetectionArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var anomalyDetectionResource = new Opensearch.AnomalyDetection("anomalyDetectionResource", new()
    {
        Body = "string",
        AnomalyDetectionId = "string",
    });
    
    example, err := opensearch.NewAnomalyDetection(ctx, "anomalyDetectionResource", &opensearch.AnomalyDetectionArgs{
    	Body:               pulumi.String("string"),
    	AnomalyDetectionId: pulumi.String("string"),
    })
    
    var anomalyDetectionResource = new AnomalyDetection("anomalyDetectionResource", AnomalyDetectionArgs.builder()
        .body("string")
        .anomalyDetectionId("string")
        .build());
    
    anomaly_detection_resource = opensearch.AnomalyDetection("anomalyDetectionResource",
        body="string",
        anomaly_detection_id="string")
    
    const anomalyDetectionResource = new opensearch.AnomalyDetection("anomalyDetectionResource", {
        body: "string",
        anomalyDetectionId: "string",
    });
    
    type: opensearch:AnomalyDetection
    properties:
        anomalyDetectionId: string
        body: string
    

    AnomalyDetection Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The AnomalyDetection resource accepts the following input properties:

    Body string
    The anomaly detection document
    AnomalyDetectionId string
    The ID of this resource.
    Body string
    The anomaly detection document
    AnomalyDetectionId string
    The ID of this resource.
    body String
    The anomaly detection document
    anomalyDetectionId String
    The ID of this resource.
    body string
    The anomaly detection document
    anomalyDetectionId string
    The ID of this resource.
    body str
    The anomaly detection document
    anomaly_detection_id str
    The ID of this resource.
    body String
    The anomaly detection document
    anomalyDetectionId String
    The ID of this resource.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the AnomalyDetection resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing AnomalyDetection Resource

    Get an existing AnomalyDetection resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: AnomalyDetectionState, opts?: CustomResourceOptions): AnomalyDetection
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            anomaly_detection_id: Optional[str] = None,
            body: Optional[str] = None) -> AnomalyDetection
    func GetAnomalyDetection(ctx *Context, name string, id IDInput, state *AnomalyDetectionState, opts ...ResourceOption) (*AnomalyDetection, error)
    public static AnomalyDetection Get(string name, Input<string> id, AnomalyDetectionState? state, CustomResourceOptions? opts = null)
    public static AnomalyDetection get(String name, Output<String> id, AnomalyDetectionState state, CustomResourceOptions options)
    resources:  _:    type: opensearch:AnomalyDetection    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    AnomalyDetectionId string
    The ID of this resource.
    Body string
    The anomaly detection document
    AnomalyDetectionId string
    The ID of this resource.
    Body string
    The anomaly detection document
    anomalyDetectionId String
    The ID of this resource.
    body String
    The anomaly detection document
    anomalyDetectionId string
    The ID of this resource.
    body string
    The anomaly detection document
    anomaly_detection_id str
    The ID of this resource.
    body str
    The anomaly detection document
    anomalyDetectionId String
    The ID of this resource.
    body String
    The anomaly detection document

    Package Details

    Repository
    opensearch opensearch-project/terraform-provider-opensearch
    License
    Notes
    This Pulumi package is based on the opensearch Terraform Provider.
    opensearch logo
    opensearch 2.3.1 published on Monday, Apr 14, 2025 by opensearch-project