Manually port policy changes

This commit is contained in:
aetter 2021-05-06 10:30:11 -07:00
parent 16fc67535c
commit 32165a4ccd
1 changed files with 58 additions and 56 deletions

View File

@ -523,70 +523,72 @@ You can use the same options for `ctx` variables as the [notification](#notifica
The following sample template policy is for a rollover use case:
1. Create a policy with an `ism_template` field.
The following sample template policy is for a rollover use case.
```json
PUT _opensearch/_ism/policies/rollover_policy
{
"policy": {
"description": "Example rollover policy.",
"default_state": "rollover",
"states": [
{
"name": "rollover",
"actions": [
{
"rollover": {
"min_doc_count": 1
}
}
],
"transitions": []
}
],
"ism_template": {
"index_patterns": ["log*"],
"priority": 100
}
}
}
```
1. Create a policy with an `ism_template` field:
You need to specify the `index_patterns` field. If you don't specify a value for `priority`, it defaults to 0.
```json
PUT _opensearch/_ism/policies/rollover_policy
{
"policy": {
"description": "Example rollover policy.",
"default_state": "rollover",
"states": [
{
"name": "rollover",
"actions": [
{
"rollover": {
"min_doc_count": 1
}
}
],
"transitions": []
}
],
"ism_template": {
"index_patterns": ["log*"],
"priority": 100
}
}
}
```
1. Set up a template with the `rollover_alias` as `log` :
You need to specify the `index_patterns` field. If you don't specify a value for `priority`, it defaults to 0.
```json
PUT _template/ism_rollover
{
"index_patterns": ["log*"],
"settings": {
"opensearch.index_state_management.rollover_alias": "log"
}
}
```
2. Set up a template with the `rollover_alias` as `log` :
1. Create an index with the `log` alias:
```json
PUT _index_template/ism_rollover
{
"index_patterns": ["log*"],
"settings": {
"opensearch.index_state_management.rollover_alias": "log"
}
}
```
```json
PUT log-000001
{
"aliases": {
"log": {
"is_write_index": true
}
}
}
```
3. Create an index with the `log` alias:
1. Index a document to trigger the rollover condition:
```json
PUT log-000001
{
"aliases": {
"log": {
"is_write_index": true
}
}
}
```
```json
POST log/_doc
{
"message": "dummy"
}
```
4. Index a document to trigger the rollover condition:
```json
POST log/_doc
{
"message": "dummy"
}
```
## Example policy