5

I'm using open distro for elasticsearch v7.7.0, I want to manage index life cycle automatically so when a new indice is created it gets automatically attached to an ISM policy. but I'm getting this error 'source alias does not point to a write index'.

Here is my configuration:

1- Logstash output

output {
elasticsearch {
hosts => ["http://myelasticsearch"]
user => "someuser"
password => "somepassword-"
#index => "demo"
index => "demo-%{+YYYY.MM.dd.HH-mm}"
       ssl => false
       ssl_certificate_verification => false
       ilm_enabled => false
}
stdout { codec => "dots"}
}

2- ISM policy

    {
    "policy": {
        "policy_id": "hot warm delete workflow",
        "description": "hot warm delete workflow",
        "last_updated_time": 1595417446751,
        "schema_version": 1,
        "error_notification": null,
        "default_state": "hot",
        "states": [
            {
                "name": "hot",
                "actions": [
                    {
                        "rollover": {
                            "min_index_age": "1d"
                        }
                    }
                ],
                "transitions": [
                    {
                        "state_name": "warm"
                    }
                ]
            },
            {
                "name": "warm",
                "actions": [
                    {
                        "replica_count": {
                            "number_of_replicas": 0
                        }
                    }
                ],
                "transitions": [
                    {
                        "state_name": "delete",
                        "conditions": {
                            "min_index_age": "30d"
                        }
                    }
                ]
            },
            {
                "name": "delete",
                "actions": [
                    {
                        "delete": {}
                    }
                ],
                "transitions": []
            }
        ]
    }
}

3- Index template

  PUT _template/my_template
{
"alias": {
    "demo": {"is_write_index": true }
  },
  "index_patterns": ["demo*"],                 
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "opendistro.index_state_management.policy_id": "hot warm delete workflow",      
    "opendistro.index_state_management.rollover_alias": "demo"  
    
  }
}

I've noticed that when the alias is created it does not get 'is_write_index": true' attribute.

Any helpful comments would be appreciated.

Amine Bouzid
  • 302
  • 3
  • 11
  • If you manually create a new index matching the index pattern of the template, what is the outcome? – ibexit Jul 25 '20 at 09:18
  • @ibexit thanks for your comment, even if I create an index, which matches the index pattern, it doesn't get the 'is_write_index: true' unless it's specified in the index creation. – Amine Bouzid Jul 25 '20 at 12:49

1 Answers1

5

I resolved the problem by myself.

For someone who is facing the same problem here is the solution.

1- First create a template:

PUT _template/my_template
{
  "index_patterns": ["demo*"],                 
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 1,
    "opendistro.index_state_management.policy_id": "hot warm delete workflow",      
    "opendistro.index_state_management.rollover_alias": "demo"  
    
  }
}

2- You need to bootstrap an initial index and designate it as the write index for the rollover alias specified in your index template:

PUT demo-000001
{
  "aliases": {
    "demo": {
      "is_write_index": true
    }
  }
}

3- Logstash output:

output {
elasticsearch {
hosts => ["http://myelasticsearch"]
user => "someuser"
password => "somepassword-"
index => "demo"
       ssl => false
       ssl_certificate_verification => false
       ilm_enabled => false      
}
stdout { codec => "dots"}
}
Amine Bouzid
  • 302
  • 3
  • 11