How to import data to influxdb in docker environment?


#1

Hi,
I’m running HA in a docker container on a rpi2.
I want to look into the whole influxdb/grafana thing and started by setting up influxdb using the hypriot/rpi-influxdb image.

Now, the documentation says that it is possible to import data from the home assistant database (dockerized mysql in my case) into InfluxDB.
The exact command is:

hass --script influxdb_import --config CONFIG_DIR \
-H IP_INFLUXDB_HOST -u INFLUXDB_USERNAME -p INFLUXDB_PASSWORD \
--dbname INFLUXDB_DB_NAME --exclude_domains automation,configurator

This approach seems to be for Hassbian / AIO installations, but not for docker setups.

How do I run this?
Can I trigger this somehow from inside the HA container?

Thanks
Jochen


#2

I tried to execute the command from within the docker container, but this freezes the whole system.
CPU consumption goes through the roof so that not even an SSH connection is working then.
Had to pull the plug after 30min…

EDIT: executing it locally from an abandoned hassbian virtual environment leads to the same result. At first it looks like there is a lot of activity in the mysql process (as expected) but after a minute or so the hass process eats up 100% cpu and the system becomes unresponsive.

My command is:

hass --script influxdb_import --uri mysql://hass:[email protected]/homeassistant -H 127.0.0.1 -P 8088 --dbname home_assistant -s 100


#3

Hi there,

Can you please share the command you managed to execute from within the docker container?

I’m trying to do the same import but from a SQLite db, maybe I have a better chance in that the script won’t freeze, but similarly to you I don’t see how to invoke it in the first place.

Thanks,
Giuseppe


#4

OK, hoping it is relevant to other readers, it is straightforward:
python -m homeassistant --script your_script
Except that in my NAS even python -m homeassistant --help takes several seconds to complete and I was impatient…


#5

I don’t quite know what you mean. The command that I tried is in my last message. Looks similar to yours except that in my container it starts with “hass” instead of homeassistant. The import script takes several parameters.


#6

Ah, that’s interesting: the docker I’m using (just the standard homeassistant/home-assistant one) does not include the hass script at all.
I found out that I simply have to run another instance of homeassistant as per the above comment. Now the import is running (for 3h already, I guess it will still take quite some time).


#7

Just for a reference, this is what works for official Home Assistant image:
python -m homeassistant --script influxdb_import --config /config -H 192.168.3.140 -P 8086 --dbname home_assistant --exclude_domains automation,configurator --simulate

If you are running your influxdb in docker, you should use public docker host address.