legrego / homeassistant-elasticsearch

Publish Home-Assistant events to Elasticsearch
https://legrego.github.io/homeassistant-elasticsearch/
MIT License
143 stars 38 forks source link

Indexing failures with existing datastreams #266

Closed strawgate closed 1 month ago

strawgate commented 1 month ago

I believe due to fields added in this PR: https://github.com/legrego/homeassistant-elasticsearch/pull/262

That beta -> beta upgraded instances will fail to index data as event.* fields will not have been defined in the index templates so when it attempts to index the document you get: reason': '[1:118] mapping set to strict, dynamic introduction of [type] within [event] is not allowed'},

strawgate commented 1 month ago

Once this merges: https://github.com/legrego/homeassistant-elasticsearch/pull/267

Anyone going from beta -> beta will have to wait a couple days for the indices to rollover or will have to manually run (via dev tools or the ES API):

PUT /metrics-homeassistant.*/_mapping
{
    "properties": {
        "data_stream": {
            "properties": {
                "type": {
                    "type": "constant_keyword",
                    "value": "metrics"
                },
                "dataset": {
                    "type": "constant_keyword"
                },
                "namespace": {
                    "type": "constant_keyword"
                }
            }
        },
        "event": {
            "properties": {
                "action": {
                    "type": "keyword",
                    "ignore_above": 1024
                },
                "type": {
                    "ignore_above": 1024,
                    "type": "keyword"
                },
                "kind": {
                    "ignore_above": 1024,
                    "type": "keyword"
                }
            }
        }
    }
}

For indexing to resume