legrego / homeassistant-elasticsearch

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

data_stream object for >= v.0.7 #265

Closed philippkahr closed 1 month ago

philippkahr commented 1 month ago

Hi,

when trying to use the new data streams metrics-homeassistant* I discovered that we are not setting the data_stream object like I am known to from other integrations.

E.g. the metrics-system.cpu-default data stream sets it like this:

          "data_stream": {
            "dataset": "system.cpu",
            "namespace": "default",
            "type": "metrics"
          },

The ECS defines them as constant_keywords which makes them really fast. https://www.elastic.co/guide/en/ecs/master/ecs-data_stream.html

I discovered it since I use the generic metrics-* as index pattern in a data view and I wanted to filter down a dashboard by adding data_stream.dataset: homeassistant*.

We can either hardcode them in the mapping or import the ecs@mappings . Afaik that mapping should be there by default.