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:
- Job
Id string - Identifier for the anomaly detection job.
- State string
- The desired state for the ML job. Valid values are
openedandclosed. - Elasticsearch
Connections List<ElasticsearchMl Job State Elasticsearch Connection> - Elasticsearch connection configuration block.
- Force bool
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- Job
Timeout string - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - Timeouts
Elasticsearch
Ml Job State Timeouts
- Job
Id string - Identifier for the anomaly detection job.
- State string
- The desired state for the ML job. Valid values are
openedandclosed. - Elasticsearch
Connections []ElasticsearchMl Job State Elasticsearch Connection Args - Elasticsearch connection configuration block.
- Force bool
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- Job
Timeout string - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - Timeouts
Elasticsearch
Ml Job State Timeouts Args
- job
Id String - Identifier for the anomaly detection job.
- state String
- The desired state for the ML job. Valid values are
openedandclosed. - elasticsearch
Connections List<ElasticsearchMl Job State Elasticsearch Connection> - Elasticsearch connection configuration block.
- force Boolean
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- job
Timeout String - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - timeouts
Elasticsearch
Ml Job State Timeouts
- job
Id string - Identifier for the anomaly detection job.
- state string
- The desired state for the ML job. Valid values are
openedandclosed. - elasticsearch
Connections ElasticsearchMl Job State Elasticsearch Connection[] - Elasticsearch connection configuration block.
- force boolean
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- job
Timeout string - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - timeouts
Elasticsearch
Ml Job State Timeouts
- job_
id str - Identifier for the anomaly detection job.
- state str
- The desired state for the ML job. Valid values are
openedandclosed. - elasticsearch_
connections Sequence[ElasticsearchMl Job State Elasticsearch Connection Args] - Elasticsearch connection configuration block.
- 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 is30s. - timeouts
Elasticsearch
Ml Job State Timeouts Args
- job
Id String - Identifier for the anomaly detection job.
- state String
- The desired state for the ML job. Valid values are
openedandclosed. - elasticsearch
Connections List<Property Map> - Elasticsearch connection configuration block.
- force Boolean
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- job
Timeout String - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - 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) -> ElasticsearchMlJobStatefunc 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.
- Elasticsearch
Connections List<ElasticsearchMl Job State Elasticsearch Connection> - Elasticsearch connection configuration block.
- Force bool
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- Job
Id string - Identifier for the anomaly detection job.
- Job
Timeout string - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - State string
- The desired state for the ML job. Valid values are
openedandclosed. - Timeouts
Elasticsearch
Ml Job State Timeouts
- Elasticsearch
Connections []ElasticsearchMl Job State Elasticsearch Connection Args - Elasticsearch connection configuration block.
- Force bool
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- Job
Id string - Identifier for the anomaly detection job.
- Job
Timeout string - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - State string
- The desired state for the ML job. Valid values are
openedandclosed. - Timeouts
Elasticsearch
Ml Job State Timeouts Args
- elasticsearch
Connections List<ElasticsearchMl Job State Elasticsearch Connection> - Elasticsearch connection configuration block.
- force Boolean
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- job
Id String - Identifier for the anomaly detection job.
- job
Timeout String - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - state String
- The desired state for the ML job. Valid values are
openedandclosed. - timeouts
Elasticsearch
Ml Job State Timeouts
- elasticsearch
Connections ElasticsearchMl Job State Elasticsearch Connection[] - Elasticsearch connection configuration block.
- force boolean
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- job
Id string - Identifier for the anomaly detection job.
- job
Timeout string - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - state string
- The desired state for the ML job. Valid values are
openedandclosed. - timeouts
Elasticsearch
Ml Job State Timeouts
- elasticsearch_
connections Sequence[ElasticsearchMl Job State Elasticsearch Connection Args] - Elasticsearch connection configuration block.
- 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 is30s. - state str
- The desired state for the ML job. Valid values are
openedandclosed. - timeouts
Elasticsearch
Ml Job State Timeouts Args
- elasticsearch
Connections List<Property Map> - Elasticsearch connection configuration block.
- force Boolean
- When closing a job, use to forcefully close it. This method is quicker but can miss important clean up tasks.
- job
Id String - Identifier for the anomaly detection job.
- job
Timeout String - Timeout for the operation. Examples:
30s,5m,1h. Default is30s. - state String
- The desired state for the ML job. Valid values are
openedandclosed. - timeouts Property Map
Supporting Types
ElasticsearchMlJobStateElasticsearchConnection, ElasticsearchMlJobStateElasticsearchConnectionArgs
- Api
Key string - API Key to use for authentication to Elasticsearch
- Bearer
Token string - Bearer Token to use for authentication to Elasticsearch
- Ca
Data string - PEM-encoded custom Certificate Authority certificate
- Ca
File string - Path to a custom Certificate Authority certificate
- Cert
Data string - PEM encoded certificate for client auth
- Cert
File string - Path to a file containing the PEM encoded certificate for client auth
- Endpoints List<string>
- Es
Client stringAuthentication - 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
- Key
Data string - PEM encoded private key for client auth
- Key
File 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 string - API Key to use for authentication to Elasticsearch
- Bearer
Token string - Bearer Token to use for authentication to Elasticsearch
- Ca
Data string - PEM-encoded custom Certificate Authority certificate
- Ca
File string - Path to a custom Certificate Authority certificate
- Cert
Data string - PEM encoded certificate for client auth
- Cert
File string - Path to a file containing the PEM encoded certificate for client auth
- Endpoints []string
- Es
Client stringAuthentication - 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
- Key
Data string - PEM encoded private key for client auth
- Key
File 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 String - API Key to use for authentication to Elasticsearch
- bearer
Token String - Bearer Token to use for authentication to Elasticsearch
- ca
Data String - PEM-encoded custom Certificate Authority certificate
- ca
File String - Path to a custom Certificate Authority certificate
- cert
Data String - PEM encoded certificate for client auth
- cert
File String - Path to a file containing the PEM encoded certificate for client auth
- endpoints List<String>
- es
Client StringAuthentication - 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
- key
Data String - PEM encoded private key for client auth
- key
File 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 string - API Key to use for authentication to Elasticsearch
- bearer
Token string - Bearer Token to use for authentication to Elasticsearch
- ca
Data string - PEM-encoded custom Certificate Authority certificate
- ca
File string - Path to a custom Certificate Authority certificate
- cert
Data string - PEM encoded certificate for client auth
- cert
File string - Path to a file containing the PEM encoded certificate for client auth
- endpoints string[]
- es
Client stringAuthentication - 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
- key
Data string - PEM encoded private key for client auth
- key
File 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_ strauthentication - 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.
- api
Key String - API Key to use for authentication to Elasticsearch
- bearer
Token String - Bearer Token to use for authentication to Elasticsearch
- ca
Data String - PEM-encoded custom Certificate Authority certificate
- ca
File String - Path to a custom Certificate Authority certificate
- cert
Data String - PEM encoded certificate for client auth
- cert
File String - Path to a file containing the PEM encoded certificate for client auth
- endpoints List<String>
- es
Client StringAuthentication - 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
- key
Data String - PEM encoded private key for client auth
- key
File 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
elasticstackTerraform Provider.
