legrego / homeassistant-elasticsearch

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

Add event.action, log duplicate documents, and store datetimes in nanosecond precision #262

Closed strawgate closed 1 month ago

strawgate commented 1 month ago

Add event.action, event.type, event.kind, log duplicate documents, and move datetimes to nanosecond precision.

Note: If testing against an existing Elasticsearch instance you will not see nanosecond datetimes until the data streams rollover as index template changes don't take effect on existing indices. You can manually invoke rollover via: POST metrics-homeassistant.*/_rollover

Fixes: #260 Maybe fixes: #261

strawgate commented 1 month ago

image

strawgate commented 1 month ago

I tried really hard to update the existing parametrized update method tests and gave up and just split out the tests.

strawgate commented 1 month ago

Kibana will show millisecond due to limitations in Kibana image

But searching the documents shows nanosecond image

github-actions[bot] commented 1 month ago

Coverage

Coverage Report
FileStmtsMissCoverMissing
__init__.py00100% 
elasticsearch
   __init__.py90297%208–209
   config_flow.py2502888%83, 122, 230, 300, 323, 337, 378–381, 383–384, 386, 388–390, 392–393, 407–408, 412, 452, 458, 498, 573, 582, 616–617
   const.py330100% 
   entity_details.py330100% 
   errors.py28389%51, 60, 67
   es_doc_creator.py1810100% 
   es_doc_publisher.py2491593%101, 243–244, 260–261, 353, 443–444, 446–447, 449–453
   es_gateway.py1002080%82–83, 98, 102, 118–120, 122, 124–125, 127–131, 133–137
   es_index_manager.py121893%228–229, 246–247, 252–253, 282–283
   es_integration.py37294%43–44
   es_privilege_check.py550100% 
   es_serializer.py10190%17
   es_version.py300100% 
   logger.py20100% 
   system_info.py17194%23
   utils.py40100% 
TOTAL12408093% 

Tests Skipped Failures Errors Time
95 0 :zzz: 0 :x: 0 :fire: 6.461s :stopwatch:
strawgate commented 1 month ago

At some point I'll probably take a stab at refactoring the doc_publisher tests...