Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions docs/resources/elasticsearch_index_lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ resource "elasticstack_elasticsearch_index_lifecycle" "my_ilm" {
Optional:

- `allocate` (Block List, Max: 1) Updates the index settings to change which nodes are allowed to host the index shards and change the number of replicas. (see [below for nested schema](#nestedblock--cold--allocate))
- `downsample` (Block List, Max: 2) Roll up documents within a fixed interval to a single summary document. Reduces the index footprint by storing time series data at reduced granularity. (see [below for nested schema](#nestedblock--cold--downsample))
- `freeze` (Block List, Max: 1) Freeze the index to minimize its memory footprint. (see [below for nested schema](#nestedblock--cold--freeze))
- `migrate` (Block List, Max: 1) Moves the index to the data tier that corresponds to the current phase by updating the "index.routing.allocation.include._tier_preference" index setting. (see [below for nested schema](#nestedblock--cold--migrate))
- `min_age` (String) ILM moves indices through the lifecycle according to their age. To control the timing of these transitions, you set a minimum age for each phase.
Expand All @@ -101,6 +102,15 @@ Optional:
- `total_shards_per_node` (Number) The maximum number of shards for the index on a single Elasticsearch node. Defaults to `-1` (unlimited). Supported from Elasticsearch version **7.16**


<a id="nestedblock--cold--downsample"></a>
### Nested Schema for `cold.downsample`

Required:

- `fixed_interval` (String) Downsampling interval
- `wait_timeout` (String) Downsampling interval


<a id="nestedblock--cold--freeze"></a>
### Nested Schema for `cold.freeze`

Expand Down Expand Up @@ -226,6 +236,7 @@ Optional:

Optional:

- `downsample` (Block List, Max: 2) Roll up documents within a fixed interval to a single summary document. Reduces the index footprint by storing time series data at reduced granularity. (see [below for nested schema](#nestedblock--hot--downsample))
- `forcemerge` (Block List, Max: 1) Force merges the index into the specified maximum number of segments. This action makes the index read-only. (see [below for nested schema](#nestedblock--hot--forcemerge))
- `min_age` (String) ILM moves indices through the lifecycle according to their age. To control the timing of these transitions, you set a minimum age for each phase.
- `readonly` (Block List, Max: 1) Makes the index read-only. (see [below for nested schema](#nestedblock--hot--readonly))
Expand All @@ -235,6 +246,15 @@ Optional:
- `shrink` (Block List, Max: 1) Sets a source index to read-only and shrinks it into a new index with fewer primary shards. (see [below for nested schema](#nestedblock--hot--shrink))
- `unfollow` (Block List, Max: 1) Convert a follower index to a regular index. Performed automatically before a rollover, shrink, or searchable snapshot action. (see [below for nested schema](#nestedblock--hot--unfollow))

<a id="nestedblock--hot--downsample"></a>
### Nested Schema for `hot.downsample`

Required:

- `fixed_interval` (String) Downsampling interval
- `wait_timeout` (String) Downsampling interval


<a id="nestedblock--hot--forcemerge"></a>
### Nested Schema for `hot.forcemerge`

Expand Down Expand Up @@ -315,6 +335,7 @@ Optional:
Optional:

- `allocate` (Block List, Max: 1) Updates the index settings to change which nodes are allowed to host the index shards and change the number of replicas. (see [below for nested schema](#nestedblock--warm--allocate))
- `downsample` (Block List, Max: 2) Roll up documents within a fixed interval to a single summary document. Reduces the index footprint by storing time series data at reduced granularity. (see [below for nested schema](#nestedblock--warm--downsample))
- `forcemerge` (Block List, Max: 1) Force merges the index into the specified maximum number of segments. This action makes the index read-only. (see [below for nested schema](#nestedblock--warm--forcemerge))
- `migrate` (Block List, Max: 1) Moves the index to the data tier that corresponds to the current phase by updating the "index.routing.allocation.include._tier_preference" index setting. (see [below for nested schema](#nestedblock--warm--migrate))
- `min_age` (String) ILM moves indices through the lifecycle according to their age. To control the timing of these transitions, you set a minimum age for each phase.
Expand All @@ -335,6 +356,15 @@ Optional:
- `total_shards_per_node` (Number) The maximum number of shards for the index on a single Elasticsearch node. Defaults to `-1` (unlimited). Supported from Elasticsearch version **7.16**


<a id="nestedblock--warm--downsample"></a>
### Nested Schema for `warm.downsample`

Required:

- `fixed_interval` (String) Downsampling interval
- `wait_timeout` (String) Downsampling interval


<a id="nestedblock--warm--forcemerge"></a>
### Nested Schema for `warm.forcemerge`

Expand Down
28 changes: 25 additions & 3 deletions internal/elasticsearch/index/ilm.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func ResourceIlm() *schema.Resource {
MaxItems: 1,
AtLeastOneOf: []string{"hot", "warm", "cold", "frozen", "delete"},
Elem: &schema.Resource{
Schema: getSchema("set_priority", "unfollow", "rollover", "readonly", "shrink", "forcemerge", "searchable_snapshot"),
Schema: getSchema("set_priority", "unfollow", "rollover", "readonly", "shrink", "forcemerge", "searchable_snapshot", "downsample"),
},
},
"warm": {
Expand All @@ -56,7 +56,7 @@ func ResourceIlm() *schema.Resource {
MaxItems: 1,
AtLeastOneOf: []string{"hot", "warm", "cold", "frozen", "delete"},
Elem: &schema.Resource{
Schema: getSchema("set_priority", "unfollow", "readonly", "allocate", "migrate", "shrink", "forcemerge"),
Schema: getSchema("set_priority", "unfollow", "readonly", "allocate", "migrate", "shrink", "forcemerge", "downsample"),
},
},
"cold": {
Expand All @@ -66,7 +66,7 @@ func ResourceIlm() *schema.Resource {
MaxItems: 1,
AtLeastOneOf: []string{"hot", "warm", "cold", "frozen", "delete"},
Elem: &schema.Resource{
Schema: getSchema("set_priority", "unfollow", "readonly", "searchable_snapshot", "allocate", "migrate", "freeze"),
Schema: getSchema("set_priority", "unfollow", "readonly", "searchable_snapshot", "allocate", "migrate", "freeze", "downsample"),
},
},
"frozen": {
Expand Down Expand Up @@ -389,6 +389,26 @@ var supportedActions = map[string]*schema.Schema{
},
},
},
"downsample": {
Description: "Roll up documents within a fixed interval to a single summary document. Reduces the index footprint by storing time series data at reduced granularity.",
Type: schema.TypeList,
Optional: true,
MaxItems: 2,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"fixed_interval": {
Description: "Downsampling interval",
Type: schema.TypeString,
Required: true,
},
"wait_timeout": {
Description: "Downsampling interval",
Type: schema.TypeString,
Required: true,
},
},
},
},
}

func getSchema(actions ...string) map[string]*schema.Schema {
Expand Down Expand Up @@ -519,6 +539,8 @@ func expandPhase(p map[string]interface{}, serverVersion *version.Version) (*mod
}
case "wait_for_snapshot":
actions[actionName], diags = expandAction(a, serverVersion, "policy")
case "downsample":
actions[actionName], diags = expandAction(a, serverVersion, "fixed_interval", "wait_timeout")
default:
diags = append(diags, diag.Diagnostic{
Severity: diag.Error,
Expand Down
7 changes: 7 additions & 0 deletions internal/elasticsearch/index/ilm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func TestAccResourceILM(t *testing.T) {
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "name", policyName),
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "hot.0.min_age", "1h"),
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "hot.0.set_priority.0.priority", "10"),
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "hot.0.downsample.0.fixed_interval", "1d"),
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "hot.0.downsample.0.wait_timeout", "1d"),
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "hot.0.rollover.0.max_age", "1d"),
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "hot.0.readonly.0.enabled", "true"),
resource.TestCheckResourceAttr("elasticstack_elasticsearch_index_lifecycle.test", "delete.0.min_age", "0ms"),
Expand Down Expand Up @@ -128,6 +130,11 @@ resource "elasticstack_elasticsearch_index_lifecycle" "test" {
max_age = "1d"
}

downsample {
fixed_interval = "1d"
wait_timeout = "1d"
}

readonly {}
}

Expand Down