1. Packages
  2. Elasticstack Provider
  3. API Docs
  4. ElasticsearchMlJobState
elasticstack 0.13.1 published on Thursday, Dec 11, 2025 by elastic
elasticstack logo
elasticstack 0.13.1 published on Thursday, Dec 11, 2025 by elastic

    Manages the state of an Elasticsearch Machine Learning (ML) job, allowing you to open or close ML jobs.

    This resource uses the following Elasticsearch APIs:

    Create ElasticsearchMlJobState Resource

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

    Constructor syntax

    new ElasticsearchMlJobState(name: string, args: ElasticsearchMlJobStateArgs, opts?: CustomResourceOptions);
    @overload
    def ElasticsearchMlJobState(resource_name: str,
                                args: ElasticsearchMlJobStateArgs,
                                opts: Optional[ResourceOptions] = None)
    
    @overload
    def ElasticsearchMlJobState(resource_name: str,
                                opts: Optional[ResourceOptions] = None,
                                job_id: Optional[str] = None,
                                state: Optional[str] = None,
                                elasticsearch_connections: Optional[Sequence[ElasticsearchMlJobStateElasticsearchConnectionArgs]] = None,
                                force: Optional[bool] = None,
                                job_timeout: Optional[str] = None,
                                timeouts: Optional[ElasticsearchMlJobStateTimeoutsArgs] = None)
    func NewElasticsearchMlJobState(ctx *Context, name string, args ElasticsearchMlJobStateArgs, opts ...ResourceOption) (*ElasticsearchMlJobState, error)
    public ElasticsearchMlJobState(string name, ElasticsearchMlJobStateArgs args, CustomResourceOptions? opts = null)
    public ElasticsearchMlJobState(String name, ElasticsearchMlJobStateArgs args)
    public ElasticsearchMlJobState(String name, ElasticsearchMlJobStateArgs args, CustomResourceOptions options)
    
    type: elasticstack:ElasticsearchMlJobState
    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 ElasticsearchMlJobStateArgs
    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 ElasticsearchMlJobStateArgs
    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 ElasticsearchMlJobStateArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args ElasticsearchMlJobStateArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args ElasticsearchMlJobStateArgs
    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 elasticsearchMlJobStateResource = new Elasticstack.ElasticsearchMlJobState("elasticsearchMlJobStateResource", new()
    {
        JobId = "string",
        State = "string",
        Force = false,
        JobTimeout = "string",
        Timeouts = new Elasticstack.Inputs.ElasticsearchMlJobStateTimeoutsArgs
        {
            Create = "string",
            Update = "string",
        },
    });
    
    example, err := elasticstack.NewElasticsearchMlJobState(ctx, "elasticsearchMlJobStateResource", &elasticstack.ElasticsearchMlJobStateArgs{
    	JobId:      pulumi.String("string"),
    	State:      pulumi.String("string"),
    	Force:      pulumi.Bool(false),
    	JobTimeout: pulumi.String("string"),
    	Timeouts: &elasticstack.ElasticsearchMlJobStateTimeoutsArgs{
    		Create: pulumi.String("string"),
    		Update: pulumi.String("string"),
    	},
    })
    
    var elasticsearchMlJobStateResource = new ElasticsearchMlJobState("elasticsearchMlJobStateResource", ElasticsearchMlJobStateArgs.builder()
        .jobId("string")
        .state("string")
        .force(false)
        .jobTimeout("string")
        .timeouts(ElasticsearchMlJobStateTimeoutsArgs.builder()
            .create("string")
            .update("string")
            .build())
        .build());
    
    elasticsearch_ml_job_state_resource = elasticstack.ElasticsearchMlJobState("elasticsearchMlJobStateResource",
        job_id="string",
        state="string",
        force=False,
        job_timeout="string",
        timeouts={
            "create": "string",
            "update": "string",
        })
    
    const elasticsearchMlJobStateResource = new elasticstack.ElasticsearchMlJobState("elasticsearchMlJobStateResource", {
        jobId: "string",
        state: "string",
        force: false,
        jobTimeout: "string",
        timeouts: {
            create: "string",
            update: "string",
        },
    });
    
    type: elasticstack:ElasticsearchMlJobState
    properties:
        force: false
        jobId: string
        jobTimeout: string
        state: string
        timeouts:
            create: string
            update: string
    

    ElasticsearchMlJobState 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 ElasticsearchMlJobState resource accepts the following input properties:

    JobId string
    Identifier for the anomaly detection job.
    State string
    The desired state for the ML job. Valid values are opened and closed.
    ElasticsearchConnections List<ElasticsearchMlJobStateElasticsearchConnection>
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    Force bool
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    JobTimeout string
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    Timeouts ElasticsearchMlJobStateTimeouts
    JobId string
    Identifier for the anomaly detection job.
    State string
    The desired state for the ML job. Valid values are opened and closed.
    ElasticsearchConnections []ElasticsearchMlJobStateElasticsearchConnectionArgs
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    Force bool
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    JobTimeout string
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    Timeouts ElasticsearchMlJobStateTimeoutsArgs
    jobId String
    Identifier for the anomaly detection job.
    state String
    The desired state for the ML job. Valid values are opened and closed.
    elasticsearchConnections List<ElasticsearchMlJobStateElasticsearchConnection>
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    force Boolean
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    jobTimeout String
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    timeouts ElasticsearchMlJobStateTimeouts
    jobId string
    Identifier for the anomaly detection job.
    state string
    The desired state for the ML job. Valid values are opened and closed.
    elasticsearchConnections ElasticsearchMlJobStateElasticsearchConnection[]
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    force boolean
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    jobTimeout string
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    timeouts ElasticsearchMlJobStateTimeouts
    job_id str
    Identifier for the anomaly detection job.
    state str
    The desired state for the ML job. Valid values are opened and closed.
    elasticsearch_connections Sequence[ElasticsearchMlJobStateElasticsearchConnectionArgs]
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    force bool
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    job_timeout str
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    timeouts ElasticsearchMlJobStateTimeoutsArgs
    jobId String
    Identifier for the anomaly detection job.
    state String
    The desired state for the ML job. Valid values are opened and closed.
    elasticsearchConnections List<Property Map>
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    force Boolean
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    jobTimeout String
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    timeouts Property Map

    Outputs

    All input properties are implicitly available as output properties. Additionally, the ElasticsearchMlJobState 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 ElasticsearchMlJobState Resource

    Get an existing ElasticsearchMlJobState 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?: ElasticsearchMlJobStateState, opts?: CustomResourceOptions): ElasticsearchMlJobState
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            elasticsearch_connections: Optional[Sequence[ElasticsearchMlJobStateElasticsearchConnectionArgs]] = None,
            force: Optional[bool] = None,
            job_id: Optional[str] = None,
            job_timeout: Optional[str] = None,
            state: Optional[str] = None,
            timeouts: Optional[ElasticsearchMlJobStateTimeoutsArgs] = None) -> ElasticsearchMlJobState
    func GetElasticsearchMlJobState(ctx *Context, name string, id IDInput, state *ElasticsearchMlJobStateState, opts ...ResourceOption) (*ElasticsearchMlJobState, error)
    public static ElasticsearchMlJobState Get(string name, Input<string> id, ElasticsearchMlJobStateState? state, CustomResourceOptions? opts = null)
    public static ElasticsearchMlJobState get(String name, Output<String> id, ElasticsearchMlJobStateState state, CustomResourceOptions options)
    resources:  _:    type: elasticstack:ElasticsearchMlJobState    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:
    ElasticsearchConnections List<ElasticsearchMlJobStateElasticsearchConnection>
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    Force bool
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    JobId string
    Identifier for the anomaly detection job.
    JobTimeout string
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    State string
    The desired state for the ML job. Valid values are opened and closed.
    Timeouts ElasticsearchMlJobStateTimeouts
    ElasticsearchConnections []ElasticsearchMlJobStateElasticsearchConnectionArgs
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    Force bool
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    JobId string
    Identifier for the anomaly detection job.
    JobTimeout string
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    State string
    The desired state for the ML job. Valid values are opened and closed.
    Timeouts ElasticsearchMlJobStateTimeoutsArgs
    elasticsearchConnections List<ElasticsearchMlJobStateElasticsearchConnection>
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    force Boolean
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    jobId String
    Identifier for the anomaly detection job.
    jobTimeout String
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    state String
    The desired state for the ML job. Valid values are opened and closed.
    timeouts ElasticsearchMlJobStateTimeouts
    elasticsearchConnections ElasticsearchMlJobStateElasticsearchConnection[]
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    force boolean
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    jobId string
    Identifier for the anomaly detection job.
    jobTimeout string
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    state string
    The desired state for the ML job. Valid values are opened and closed.
    timeouts ElasticsearchMlJobStateTimeouts
    elasticsearch_connections Sequence[ElasticsearchMlJobStateElasticsearchConnectionArgs]
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    force bool
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    job_id str
    Identifier for the anomaly detection job.
    job_timeout str
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    state str
    The desired state for the ML job. Valid values are opened and closed.
    timeouts ElasticsearchMlJobStateTimeoutsArgs
    elasticsearchConnections List<Property Map>
    Elasticsearch connection configuration block.

    Deprecated: Deprecated

    force Boolean
    When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
    jobId String
    Identifier for the anomaly detection job.
    jobTimeout String
    Timeout for the operation. Examples: 30s, 5m, 1h. Default is 30s.
    state String
    The desired state for the ML job. Valid values are opened and closed.
    timeouts Property Map

    Supporting Types

    ElasticsearchMlJobStateElasticsearchConnection, ElasticsearchMlJobStateElasticsearchConnectionArgs

    ApiKey string
    API Key to use for authentication to Elasticsearch
    BearerToken string
    Bearer Token to use for authentication to Elasticsearch
    CaData string
    PEM-encoded custom Certificate Authority certificate
    CaFile string
    Path to a custom Certificate Authority certificate
    CertData string
    PEM encoded certificate for client auth
    CertFile string
    Path to a file containing the PEM encoded certificate for client auth
    Endpoints List<string>
    EsClientAuthentication string
    ES Client Authentication field to be used with the JWT token
    Headers Dictionary<string, string>
    A list of headers to be sent with each request to Elasticsearch.
    Insecure bool
    Disable TLS certificate validation
    KeyData string
    PEM encoded private key for client auth
    KeyFile string
    Path to a file containing the PEM encoded private key for client auth
    Password string
    Password to use for API authentication to Elasticsearch.
    Username string
    Username to use for API authentication to Elasticsearch.
    ApiKey string
    API Key to use for authentication to Elasticsearch
    BearerToken string
    Bearer Token to use for authentication to Elasticsearch
    CaData string
    PEM-encoded custom Certificate Authority certificate
    CaFile string
    Path to a custom Certificate Authority certificate
    CertData string
    PEM encoded certificate for client auth
    CertFile string
    Path to a file containing the PEM encoded certificate for client auth
    Endpoints []string
    EsClientAuthentication string
    ES Client Authentication field to be used with the JWT token
    Headers map[string]string
    A list of headers to be sent with each request to Elasticsearch.
    Insecure bool
    Disable TLS certificate validation
    KeyData string
    PEM encoded private key for client auth
    KeyFile string
    Path to a file containing the PEM encoded private key for client auth
    Password string
    Password to use for API authentication to Elasticsearch.
    Username string
    Username to use for API authentication to Elasticsearch.
    apiKey String
    API Key to use for authentication to Elasticsearch
    bearerToken String
    Bearer Token to use for authentication to Elasticsearch
    caData String
    PEM-encoded custom Certificate Authority certificate
    caFile String
    Path to a custom Certificate Authority certificate
    certData String
    PEM encoded certificate for client auth
    certFile String
    Path to a file containing the PEM encoded certificate for client auth
    endpoints List<String>
    esClientAuthentication String
    ES Client Authentication field to be used with the JWT token
    headers Map<String,String>
    A list of headers to be sent with each request to Elasticsearch.
    insecure Boolean
    Disable TLS certificate validation
    keyData String
    PEM encoded private key for client auth
    keyFile String
    Path to a file containing the PEM encoded private key for client auth
    password String
    Password to use for API authentication to Elasticsearch.
    username String
    Username to use for API authentication to Elasticsearch.
    apiKey string
    API Key to use for authentication to Elasticsearch
    bearerToken string
    Bearer Token to use for authentication to Elasticsearch
    caData string
    PEM-encoded custom Certificate Authority certificate
    caFile string
    Path to a custom Certificate Authority certificate
    certData string
    PEM encoded certificate for client auth
    certFile string
    Path to a file containing the PEM encoded certificate for client auth
    endpoints string[]
    esClientAuthentication string
    ES Client Authentication field to be used with the JWT token
    headers {[key: string]: string}
    A list of headers to be sent with each request to Elasticsearch.
    insecure boolean
    Disable TLS certificate validation
    keyData string
    PEM encoded private key for client auth
    keyFile string
    Path to a file containing the PEM encoded private key for client auth
    password string
    Password to use for API authentication to Elasticsearch.
    username string
    Username to use for API authentication to Elasticsearch.
    api_key str
    API Key to use for authentication to Elasticsearch
    bearer_token str
    Bearer Token to use for authentication to Elasticsearch
    ca_data str
    PEM-encoded custom Certificate Authority certificate
    ca_file str
    Path to a custom Certificate Authority certificate
    cert_data str
    PEM encoded certificate for client auth
    cert_file str
    Path to a file containing the PEM encoded certificate for client auth
    endpoints Sequence[str]
    es_client_authentication str
    ES Client Authentication field to be used with the JWT token
    headers Mapping[str, str]
    A list of headers to be sent with each request to Elasticsearch.
    insecure bool
    Disable TLS certificate validation
    key_data str
    PEM encoded private key for client auth
    key_file str
    Path to a file containing the PEM encoded private key for client auth
    password str
    Password to use for API authentication to Elasticsearch.
    username str
    Username to use for API authentication to Elasticsearch.
    apiKey String
    API Key to use for authentication to Elasticsearch
    bearerToken String
    Bearer Token to use for authentication to Elasticsearch
    caData String
    PEM-encoded custom Certificate Authority certificate
    caFile String
    Path to a custom Certificate Authority certificate
    certData String
    PEM encoded certificate for client auth
    certFile String
    Path to a file containing the PEM encoded certificate for client auth
    endpoints List<String>
    esClientAuthentication String
    ES Client Authentication field to be used with the JWT token
    headers Map<String>
    A list of headers to be sent with each request to Elasticsearch.
    insecure Boolean
    Disable TLS certificate validation
    keyData String
    PEM encoded private key for client auth
    keyFile String
    Path to a file containing the PEM encoded private key for client auth
    password String
    Password to use for API authentication to Elasticsearch.
    username String
    Username to use for API authentication to Elasticsearch.

    ElasticsearchMlJobStateTimeouts, ElasticsearchMlJobStateTimeoutsArgs

    Create string
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    Update string
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    Create string
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    Update string
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    create String
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    update String
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    create string
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    update string
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    create str
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    update str
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    create String
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
    update String
    A string that can be parsed as a duration consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

    Import

    ant Notes

    • This resource manages the state of an existing ML job, not the job configuration itself.
    • The ML job must already exist before using this resource.
    • Opening a job allows it to receive and process data.
    • Closing a job stops data processing and frees up resources.
    • Jobs can be opened and closed multiple times throughout their lifecycle.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as elasticstack from "@pulumi/elasticstack";
    
    // First create an ML anomaly detection job
    const example = new elasticstack.index.ElasticsearchMlAnomalyDetector("example", {
        jobId: "example-ml-job",
        description: "Example anomaly detection job",
        analysisConfig: {
            bucketSpan: "15m",
            detectors: [{
                "function": "count",
                detectorDescription: "Count detector",
            }],
        },
        dataDescription: {
            timeField: "@timestamp",
            timeFormat: "epoch_ms",
        },
    });
    // Manage the state of the ML job - open it
    const exampleElasticsearchMlJobState = new elasticstack.ElasticsearchMlJobState("example", {
        jobId: example.jobId,
        state: "opened",
        force: false,
        jobTimeout: "30s",
    }, {
        dependsOn: [example],
    });
    // Example with different configuration options
    const exampleWithOptions = new elasticstack.ElasticsearchMlJobState("example_with_options", {
        jobId: example.jobId,
        state: "closed",
        force: true,
        jobTimeout: "2m",
    }, {
        dependsOn: [example],
    });
    
    import pulumi
    import pulumi_elasticstack as elasticstack
    
    # First create an ML anomaly detection job
    example = elasticstack.index.ElasticsearchMlAnomalyDetector("example",
        job_id=example-ml-job,
        description=Example anomaly detection job,
        analysis_config={
            bucketSpan: 15m,
            detectors: [{
                function: count,
                detectorDescription: Count detector,
            }],
        },
        data_description={
            timeField: @timestamp,
            timeFormat: epoch_ms,
        })
    # Manage the state of the ML job - open it
    example_elasticsearch_ml_job_state = elasticstack.ElasticsearchMlJobState("example",
        job_id=example["jobId"],
        state="opened",
        force=False,
        job_timeout="30s",
        opts = pulumi.ResourceOptions(depends_on=[example]))
    # Example with different configuration options
    example_with_options = elasticstack.ElasticsearchMlJobState("example_with_options",
        job_id=example["jobId"],
        state="closed",
        force=True,
        job_timeout="2m",
        opts = pulumi.ResourceOptions(depends_on=[example]))
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Elasticstack = Pulumi.Elasticstack;
    
    return await Deployment.RunAsync(() => 
    {
        // First create an ML anomaly detection job
        var example = new Elasticstack.Index.ElasticsearchMlAnomalyDetector("example", new()
        {
            JobId = "example-ml-job",
            Description = "Example anomaly detection job",
            AnalysisConfig = 
            {
                { "bucketSpan", "15m" },
                { "detectors", new[]
                {
                    
                    {
                        { "function", "count" },
                        { "detectorDescription", "Count detector" },
                    },
                } },
            },
            DataDescription = 
            {
                { "timeField", "@timestamp" },
                { "timeFormat", "epoch_ms" },
            },
        });
    
        // Manage the state of the ML job - open it
        var exampleElasticsearchMlJobState = new Elasticstack.ElasticsearchMlJobState("example", new()
        {
            JobId = example.JobId,
            State = "opened",
            Force = false,
            JobTimeout = "30s",
        }, new CustomResourceOptions
        {
            DependsOn =
            {
                example,
            },
        });
    
        // Example with different configuration options
        var exampleWithOptions = new Elasticstack.ElasticsearchMlJobState("example_with_options", new()
        {
            JobId = example.JobId,
            State = "closed",
            Force = true,
            JobTimeout = "2m",
        }, new CustomResourceOptions
        {
            DependsOn =
            {
                example,
            },
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/elasticstack/elasticstack"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		// First create an ML anomaly detection job
    		example, err := elasticstack.NewElasticsearchMlAnomalyDetector(ctx, "example", &elasticstack.ElasticsearchMlAnomalyDetectorArgs{
    			JobId:       "example-ml-job",
    			Description: "Example anomaly detection job",
    			AnalysisConfig: map[string]interface{}{
    				"bucketSpan": "15m",
    				"detectors": []map[string]interface{}{
    					map[string]interface{}{
    						"function":            "count",
    						"detectorDescription": "Count detector",
    					},
    				},
    			},
    			DataDescription: map[string]interface{}{
    				"timeField":  "@timestamp",
    				"timeFormat": "epoch_ms",
    			},
    		})
    		if err != nil {
    			return err
    		}
    		// Manage the state of the ML job - open it
    		_, err = elasticstack.NewElasticsearchMlJobState(ctx, "example", &elasticstack.ElasticsearchMlJobStateArgs{
    			JobId:      example.JobId,
    			State:      pulumi.String("opened"),
    			Force:      pulumi.Bool(false),
    			JobTimeout: pulumi.String("30s"),
    		}, pulumi.DependsOn([]pulumi.Resource{
    			example,
    		}))
    		if err != nil {
    			return err
    		}
    		// Example with different configuration options
    		_, err = elasticstack.NewElasticsearchMlJobState(ctx, "example_with_options", &elasticstack.ElasticsearchMlJobStateArgs{
    			JobId:      example.JobId,
    			State:      pulumi.String("closed"),
    			Force:      pulumi.Bool(true),
    			JobTimeout: pulumi.String("2m"),
    		}, pulumi.DependsOn([]pulumi.Resource{
    			example,
    		}))
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.elasticstack.ElasticsearchMlAnomalyDetector;
    import com.pulumi.elasticstack.ElasticsearchMlAnomalyDetectorArgs;
    import com.pulumi.elasticstack.ElasticsearchMlJobState;
    import com.pulumi.elasticstack.ElasticsearchMlJobStateArgs;
    import com.pulumi.resources.CustomResourceOptions;
    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) {
            // First create an ML anomaly detection job
            var example = new ElasticsearchMlAnomalyDetector("example", ElasticsearchMlAnomalyDetectorArgs.builder()
                .jobId("example-ml-job")
                .description("Example anomaly detection job")
                .analysisConfig(Map.ofEntries(
                    Map.entry("bucketSpan", "15m"),
                    Map.entry("detectors", List.of(Map.ofEntries(
                        Map.entry("function", "count"),
                        Map.entry("detectorDescription", "Count detector")
                    )))
                ))
                .dataDescription(Map.ofEntries(
                    Map.entry("timeField", "@timestamp"),
                    Map.entry("timeFormat", "epoch_ms")
                ))
                .build());
    
            // Manage the state of the ML job - open it
            var exampleElasticsearchMlJobState = new ElasticsearchMlJobState("exampleElasticsearchMlJobState", ElasticsearchMlJobStateArgs.builder()
                .jobId(example.jobId())
                .state("opened")
                .force(false)
                .jobTimeout("30s")
                .build(), CustomResourceOptions.builder()
                    .dependsOn(example)
                    .build());
    
            // Example with different configuration options
            var exampleWithOptions = new ElasticsearchMlJobState("exampleWithOptions", ElasticsearchMlJobStateArgs.builder()
                .jobId(example.jobId())
                .state("closed")
                .force(true)
                .jobTimeout("2m")
                .build(), CustomResourceOptions.builder()
                    .dependsOn(example)
                    .build());
    
        }
    }
    
    resources:
      # First create an ML anomaly detection job
      example:
        type: elasticstack:ElasticsearchMlAnomalyDetector
        properties:
          jobId: example-ml-job
          description: Example anomaly detection job
          analysisConfig:
            bucketSpan: 15m
            detectors:
              - function: count
                detectorDescription: Count detector
          dataDescription:
            timeField: '@timestamp'
            timeFormat: epoch_ms
      # Manage the state of the ML job - open it
      exampleElasticsearchMlJobState:
        type: elasticstack:ElasticsearchMlJobState
        name: example
        properties:
          jobId: ${example.jobId}
          state: opened
          force: false
          jobTimeout: 30s
        options:
          dependsOn:
            - ${example}
      # Example with different configuration options
      exampleWithOptions:
        type: elasticstack:ElasticsearchMlJobState
        name: example_with_options
        properties:
          jobId: ${example.jobId}
          state: closed
          force: true # Custom timeout
          jobTimeout: 2m
        options:
          dependsOn:
            - ${example}
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    elasticstack elastic/terraform-provider-elasticstack
    License
    Notes
    This Pulumi package is based on the elasticstack Terraform Provider.
    elasticstack logo
    elasticstack 0.13.1 published on Thursday, Dec 11, 2025 by elastic
      Meet Neo: Your AI Platform Teammate