legrego / homeassistant-elasticsearch

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

host.hostname value in Elasticsearch is 'homeassistant', which is not the actual hostname #101

Closed eloebl closed 3 years ago

eloebl commented 4 years ago

Environment Home-Assistant version 0.110.2 Elasticsearch version: 7.7

Relevant configuration.yml settings:

elastic:
    url: REDACTED
    username: !secret elastic_user
    password: !secret elastic_password
    verify_ssl: true
    ssl_ca_path: !secret elastic_capath
    exclude:
        entities: ['sensor.ted1000_volts', 'sensor.ted1000_kw']

Describe the bug My home assistant instance has a different name and a full fqdn, so home02.somedomain.com . host.hostname seems to be fixed on "homeassistant" . Not sure if this is expected or not.

Screenshot image

Expected behavior Show actual host name for host.hostname

Additional context

    "host.architecture": "x86_64",
    "host.os.name": "Linux",
    "host.hostname": "homeassistant",
    "tags": [
      "hass"
    ]

Thank you!

legrego commented 4 years ago

Hey @mloebl, I believe this is expected. This field is meant to store the machine’s host name (commonly found in ‘/etc/hostname’), as opposed to the resolved FQDN that HASS is exposed on.

legrego commented 4 years ago

I take my comment back, I'd expect this to be the same hostname that HASSOS is reporting for you above. I don't run HASSOS, so I'm not sure how to go about debugging this just yet

eloebl commented 4 years ago

I'm up to try whatever you need, not a huge priority issue obviously, but something I noticed when looking in Elastic. Initially I had it running on a Raspberry Pi, then a VM, and then moved it over to a physical box to get a bit more performance out of it. On those 3 platforms it did let me set the hostname there.

legrego commented 4 years ago

Cross-posted here: https://community.home-assistant.io/t/get-hostname-from-hassos-installation/201389

eloebl commented 3 years ago

I wonder if you could use instead use internal_url from https://www.home-assistant.io/docs/configuration/basic/ . Wondering if related to how it's running in the docker container that's messing up the gethostname?

legrego commented 3 years ago

I think I managed to fix this in https://github.com/legrego/homeassistant-elasticsearch/pull/131. I'm running Home Assistant OS myself now, and I can see the updated hostname reflected in Elasticsearch now. This will be available in the upcoming v0.4.0 release.