Homeassistant container folder taking 67 gigs of space due to json log

Hi, I have homeassistant supervised and my disk space is rapidly decreasing from the homeassistant container getting bigger and bigger.

inside the homeassistant docker folder is a file called "4b5df15ec2a55d982a6a5f8f96f5e963d5b72d0e834cb445c61a70a951dfe79f-json.log " which is 65gb…

Can I delete this? I plan to shut down homeassistant and delete it.

Is there a way to set it to prune automatically? It seems docker has this functionality as below but don’t want to mess up supervisor. Shouldn’t supervisor have an option to be setting this already?

--log-opt max-size=10m --log-opt max-file=3

Would be helpful if you had posted the actual path, but I believe you have come across the output logs from HA into Docker.

If I’m correct, this has nothing to do with HA.

Have a look at this StackOverflow question and answer to see how to apply log rotation thresholds on your container.

Path is

/var/lib/docker/containers/4b5df15ec2a55d982a6a5f8f96f5e963d5b72d0e834cb445c61a70a951dfe79f#

Which is the homeassistant docker container. It is filled with stuff that looks awfully similar to the hass logs… Here’s a snippet:

{"log":"2020-09-09 18:05:52 DEBUG (MainThread) [pydreamscreen.devices] setting _hdmi_active_channels to 2\n","stream":"stderr","time":
{"log":"2020-09-09 18:05:52 DEBUG (MainThread) [pydreamscreen.devices] setting _hdr_tone_remapping to 0\n","stream":"stderr","time":"2
{"log":"2020-09-09 18:05:53 DEBUG (SyncWorker_3) [custom_components.fully_kiosk.display] Sending deviceInfo command to http://10.10.10
{"log":"2020-09-09 18:05:53 DEBUG (SyncWorker_2) [custom_components.smartthinq_sensors] Updating smartthinq device WASHER\n","stream":
{"log":"2020-09-09 18:05:53 DEBUG (SyncWorker_2) [custom_components.smartthinq_sensors] Polling...\n","stream":"stderr","time":"2020-0
{"log":"2020-09-09 18:05:53 DEBUG (SyncWorker_2) [custom_components.smartthinq_sensors.wideq.core_v2] lgedm2_post before: https://eic.
{"log":"2020-09-09 18:05:53 DEBUG (SyncWorker_2) [custom_components.smartthinq_sensors.wideq.core_v2] lgedm2_post after: {'lgedmRoot':","time":"2020-09-09T16:05:53.885694058Z"}
{"log":"2020-09-09 18:05:53 DEBUG (SyncWorker_2) [custom_components.smartthinq_sensors] Device not connected. Status not available\n",
{"log":"2020-09-09 18:05:53 DEBUG (MainThread) [custom_components.smartthinq_sensors.sensor] Updating WASHER Wash Completed state by d
{"log":"2020-09-09 18:05:53 DEBUG (MainThread) [custom_components.smartthinq_sensors.sensor] Updating WASHER Error State state by disp
{"log":"2020-09-09 18:05:54 DEBUG (SyncWorker_1) [custom_components.fully_kiosk.display] Sending deviceInfo command to http://10.10.10
{"log":"2020-09-09 18:05:54 DEBUG (MainThread) [homeassistant.core] Bus:Handling \u003cEvent state_changed[L]: entity_id=display.kindl5, mac_address=14:91:38:FE:13:4C, version=1.40.2, page=http://10.10.10.20:8123/lovelace/1, battery_charging=True, battery_level=100, dloset, supported_features=15 @ 2020-09-09T18:03:54.473714+02:00\u003e, new_state=\u003cstate display.kindle_fire_master_closet=off; maace/1, battery_charging=True, battery_level=100, display_resolution=1280x800, brightness=0, kiosk_mode=True, maintenance_mode=False, sam":"stderr","time":"2020-09-09T16:05:54.258527391Z"}

Anyhow, I deleted it and had to reboot the machine to get it to release the file handler and the associated space, but now I have 67GB more free space.

I would still like to know the right way to set up pruning for it though.

Or if it’s just a duplicate of the homeassistant log, just to turn it off, as I already have one log… It’s plenty.

That’s because it is hass logs.

Docker saves all STOUT of containers into logs for said container.
That happens for all your containers; ever.

If you cared to click the link I found you, you would have been able to see how to truncate the logs mate.

If you will look at my original post, you will see that I already listed the docker log rotation options

--log-opt max-size=10m --log-opt max-file=3

Which I think were lifted from the exact stackoverflow thread you linked to or at least someplace similar. My original question was how I indicate to supervisor that I want to do this? I’d like to do it in the “right way” that supervisor will accept and not overwrite.

I didn’t notice that line. My apologies.

I can’t find any options specifically.
If you are able to navigate the host which has the Docker container, then you should be able to do so.

I have my HA as a stand-alone container, and change any options with docker-compose for ease of configuration.

Yeah if it was docker-compose it would be easy… But supervisor is a bit of a black box and as far as I can tell, there’s no facility for doing this easily.

I can ssh to the host and/or to go look at the container in portainer, but I can’t really add options… I’m sure supervisor has these options in some file somewhere, but I don’t know where and whether they are safe to edit.

Honestly, I dropped supervisor very quickly for that reason.
I don’t mind getting my hands dirty deploying my own containers!

Hopefully someone can assist with those options; though I wouldn’t be surprised if there aren’t any due to the restricted nature.

Best of luck!

The OS do not use json logging, it uses journald https://github.com/home-assistant/operating-system/blob/ec1561661b802c296b27f802f7e9143af5ac2e4a/buildroot-external/rootfs-overlay/etc/systemd/system/docker.service.d/hassos.conf#L6

This is a supervised installation on a custom OS right?

Make sure you set the logging for docker to journald there as well, as stated in the ADR for supervised installations.
https://github.com/home-assistant/architecture/blob/3a280053dbd12c80776ba271155a95c9ebb666b2/adr/0014-home-assistant-supervised.md

ProTip: The installation script does that for you https://github.com/home-assistant/supervised-installer/blob/c384c3bee277dd645788b3a72641884ca8fe8352/installer.sh#L47-L51

2 Likes

Yep, it’s supervised on Ubuntu. Good one, that’s probably my issue. I will try it… Waiting for the new installer script , then I will migrate to debian and do it all as officially prescribed in the new docs whenever they come.

There’s a post in the SO thread about changing daemon.json so those defaults apply to newly created containers. I ran this script to truncate the logs once for a few existing containers https://www.axllent.org/docs/clear-docker-log/ but then just ended up recreating them all after making the daemon.json changes.

1 Like

They are already available. Follow ADR-0014 and run the script.

That’s not the impression I got last week from @frenck:

To be honest, I find the whole thing totally confusing.

The installer may change, but the end result will still be HA Supervised following the guidelines of ADR-0014.

You’re making far too much out of it.

To me it feels like they are making a pretty big effort to hide that installer page that you linked. There is zero mention of it from the install documentation.

And given the comments on ADR-0014 and other places, it looks like they do plan some much more official type of documentation and installer. I just don’t see the point in doing it some unofficial way when the official way is still coming… I mean I already have an unofficial version of supervised running. I don’t like migrating multiple times.

Eh?
https://www.home-assistant.io/docs/installation/#alternative-installs

2 Likes

Debian is the official way to install, it’s been widely documented, I’m not sure what else you’re looking for to make it “more” official. I think I’ve mentioned to you in another thread, it takes under and hour to do.

If you think you might break your current setup, swap the drive out for another one that way you can put your working install back in.

  1. Install Debian 10
  2. Install the dependencies and stop modem manager
sudo -i
apt-get install -y software-properties-common apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager
systemctl disable ModemManager
systemctl stop ModemManager
  1. Install Docker-ce
curl -fsSL get.docker.com | sh
  1. Run the install script
curl -sL https://raw.githubusercontent.com/home-assistant/supervised-installer/master/installer.sh | bash -s

That’s an abbreviated version of the steps, but it is literally that simple. I did 10-12 installs exactly this way today in VMs testing a script I was working on.

I’ll do you a deal, if some other version of instructions comes along that breaks your install after following the currently documented way, I’ll donate $100 to your charity of choice.

2 Likes

Okay you got me there, I missed that they snuck that line in a couple weeks ago.

Okay, you and @kanga_who have goaded me into getting on with it :wink: Thanks for the clarification. I know I can be difficult to convince at times, but after 25 years in IT, I’ve got a lot of internal boxes I check before doing major system migrations.