- 
                Notifications
    You must be signed in to change notification settings 
- Fork 121
Add ML job state resource #1337
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| --- | ||
| page_title: "elasticstack_elasticsearch_ml_job_state Resource - terraform-provider-elasticstack" | ||
| subcategory: "" | ||
| description: |- | ||
| ML Job State Resource | ||
| 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: | ||
| Open ML Job API https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.htmlClose ML Job API https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.htmlGet ML Job Stats API https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html | ||
| Important 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. | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: For some reason there aren't any spaces after periods in this snippet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure where this frontmatter description is used, but the formatting is stripped here in all the docs. In this case, it looks like the result for stripping a markdown list back to plain text. | ||
| --- | ||
|  | ||
| # elasticstack_elasticsearch_ml_job_state (Resource) | ||
|  | ||
| # ML Job State Resource | ||
|  | ||
| 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: | ||
| - [Open ML Job API](https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-open-job.html) | ||
| - [Close ML Job API](https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-close-job.html) | ||
| - [Get ML Job Stats API](https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html) | ||
|  | ||
| ## Important 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 | ||
|  | ||
| ```terraform | ||
| provider "elasticstack" { | ||
| elasticsearch {} | ||
| } | ||
| # First create an ML anomaly detection job | ||
| resource "elasticstack_elasticsearch_ml_anomaly_detector" "example" { | ||
| job_id = "example-ml-job" | ||
| description = "Example anomaly detection job" | ||
| analysis_config = { | ||
| bucket_span = "15m" | ||
| detectors = [ | ||
| { | ||
| function = "count" | ||
| detector_description = "Count detector" | ||
| } | ||
| ] | ||
| } | ||
| data_description = { | ||
| time_field = "@timestamp" | ||
| time_format = "epoch_ms" | ||
| } | ||
| } | ||
| # Manage the state of the ML job - open it | ||
| resource "elasticstack_elasticsearch_ml_job_state" "example" { | ||
| job_id = elasticstack_elasticsearch_ml_anomaly_detector.example.job_id | ||
| state = "opened" | ||
| # Optional settings | ||
| force = false | ||
| job_timeout = "30s" | ||
| # Timeouts for asynchronous operations | ||
| timeouts { | ||
| create = "5m" | ||
| update = "5m" | ||
| } | ||
| depends_on = [elasticstack_elasticsearch_ml_anomaly_detector.example] | ||
| } | ||
| # Example with different configuration options | ||
| resource "elasticstack_elasticsearch_ml_job_state" "example_with_options" { | ||
| job_id = elasticstack_elasticsearch_ml_anomaly_detector.example.job_id | ||
| state = "closed" | ||
| # Use force close for quicker shutdown | ||
| force = true | ||
| # Custom timeout | ||
| job_timeout = "2m" | ||
| # Custom timeouts for asynchronous operations | ||
| timeouts { | ||
| create = "10m" | ||
| update = "3m" | ||
| } | ||
| depends_on = [elasticstack_elasticsearch_ml_anomaly_detector.example] | ||
| } | ||
| ``` | ||
|  | ||
| <!-- schema generated by tfplugindocs --> | ||
| ## Schema | ||
|  | ||
| ### Required | ||
|  | ||
| - `job_id` (String) Identifier for the anomaly detection job. | ||
| - `state` (String) The desired state for the ML job. Valid values are `opened` and `closed`. | ||
|  | ||
| ### Optional | ||
|  | ||
| - `elasticsearch_connection` (Block List, Deprecated) Elasticsearch connection configuration block. (see [below for nested schema](#nestedblock--elasticsearch_connection)) | ||
| - `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 is `30s`. | ||
| - `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts)) | ||
|  | ||
| ### Read-Only | ||
|  | ||
| - `id` (String) Internal identifier of the resource | ||
|  | ||
| <a id="nestedblock--elasticsearch_connection"></a> | ||
| ### Nested Schema for `elasticsearch_connection` | ||
|  | ||
| Optional: | ||
|  | ||
| - `api_key` (String, Sensitive) API Key to use for authentication to Elasticsearch | ||
| - `bearer_token` (String, Sensitive) 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 of String, Sensitive) A list of endpoints where the terraform provider will point to, this must include the http(s) schema and port number. | ||
| - `es_client_authentication` (String, Sensitive) ES Client Authentication field to be used with the JWT token | ||
| - `headers` (Map of String, Sensitive) A list of headers to be sent with each request to Elasticsearch. | ||
| - `insecure` (Boolean) Disable TLS certificate validation | ||
| - `key_data` (String, Sensitive) 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, Sensitive) Password to use for API authentication to Elasticsearch. | ||
| - `username` (String) Username to use for API authentication to Elasticsearch. | ||
|  | ||
|  | ||
| <a id="nestedatt--timeouts"></a> | ||
| ### Nested Schema for `timeouts` | ||
|  | ||
| Optional: | ||
|  | ||
| - `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) 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](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| provider "elasticstack" { | ||
| elasticsearch {} | ||
| } | ||
|  | ||
| # First create an ML anomaly detection job | ||
| resource "elasticstack_elasticsearch_ml_anomaly_detector" "example" { | ||
| job_id = "example-ml-job" | ||
| description = "Example anomaly detection job" | ||
|  | ||
| analysis_config = { | ||
| bucket_span = "15m" | ||
| detectors = [ | ||
| { | ||
| function = "count" | ||
| detector_description = "Count detector" | ||
| } | ||
| ] | ||
| } | ||
|  | ||
| data_description = { | ||
| time_field = "@timestamp" | ||
| time_format = "epoch_ms" | ||
| } | ||
| } | ||
|  | ||
| # Manage the state of the ML job - open it | ||
| resource "elasticstack_elasticsearch_ml_job_state" "example" { | ||
| job_id = elasticstack_elasticsearch_ml_anomaly_detector.example.job_id | ||
| state = "opened" | ||
|  | ||
| # Optional settings | ||
| force = false | ||
| job_timeout = "30s" | ||
|  | ||
| # Timeouts for asynchronous operations | ||
| timeouts { | ||
| create = "5m" | ||
| update = "5m" | ||
| } | ||
|  | ||
| depends_on = [elasticstack_elasticsearch_ml_anomaly_detector.example] | ||
| } | ||
|  | ||
| # Example with different configuration options | ||
| resource "elasticstack_elasticsearch_ml_job_state" "example_with_options" { | ||
| job_id = elasticstack_elasticsearch_ml_anomaly_detector.example.job_id | ||
| state = "closed" | ||
|  | ||
| # Use force close for quicker shutdown | ||
| force = true | ||
|  | ||
| # Custom timeout | ||
| job_timeout = "2m" | ||
|  | ||
| # Custom timeouts for asynchronous operations | ||
| timeouts { | ||
| create = "10m" | ||
| update = "3m" | ||
| } | ||
|  | ||
| depends_on = [elasticstack_elasticsearch_ml_anomaly_detector.example] | ||
| } | 
Uh oh!
There was an error while loading. Please reload this page.