3

I would like to disable fluentd on a VM instance running Container-Optimized OS on Google compute engine.

The reason being that it is eating up a lot of RAM for functionalities I do not require.

$ ps aux --sort -rss
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root        1040  0.7 49.1 5149544 294484 ?      Sl   15:07   0:03 /opt/google-fluentd/embedded/bin/ruby -Eascii-8bit:ascii-8bit /usr/sbin/google-fluentd --under-supervisor
root         286  0.2 12.3 780428 73844 ?        Ssl  15:07   0:00 /usr/bin/dockerd --registry-mirror=https://mirror.gcr.io --host=fd:// --containerd=/var/run/containerd/containerd.sock
root         791  0.4  9.0 304208 54068 ?        Ssl  15:07   0:01 /opt/google-fluentd/embedded/bin/ruby /usr/sbin/google-fluentd
root         334  0.0  7.3 609056 44100 ?        Ssl  15:07   0:00 /usr/bin/docker run --rm --name=stackdriver-logging-agent -v /etc/stackdriver/logging.config.d/:/etc/google-fluentd/config.d/ -v /var/log:/var/log 
root         333  0.0  7.3 535324 43820 ?        Ssl  15:07   0:00 /usr/bin/docker events

The process is linked to this systemd service.

$ systemctl status stackdriver-logging.service
● stackdriver-logging.service - Fluentd container for Stackdriver Logging
   Loaded: loaded (/usr/lib/systemd/system/stackdriver-logging.service; static; vendor preset: disabled)
   Active: active (running) since Mon 2019-08-26 12:27:03 UTC; 1min 6s ago
  Process: 335 ExecStartPre=/bin/mkdir -p /var/log/google-fluentd/ (code=exited, status=0/SUCCESS)
 Main PID: 337 (docker)
    Tasks: 7 (limit: 664)
   Memory: 35.6M
      CPU: 81ms
   CGroup: /system.slice/stackdriver-logging.service
           └─337 /usr/bin/docker run --rm --name=stackdriver-logging-agent -v /etc/stackdriver/logging.config.d/:/etc/google-fluentd/config.d/ -v /var/log:/var/log -v /var/lib/docker/containers/:/var/lib/docker/containers/ gcr.io/stackdriver-agents/stackdriver-logging-agent:0.2-1.5.33-1-1

However if I try to disable it using:

$ sudo systemctl disable --now stackdriver-logging.service

The disabling doesn't survive a restart of the VM.

3 Answers3

1

Google Cloud CLI (Google Cloud SDK 283.0.0) worked for me:

gcloud compute instances add-metadata <instance_name> --metadata="google-logging-enabled=false"

1

Just delete metadata responsible for starting the logging service from the instance using console interface

enter image description here

or remove it using gcloud compute instances remove-metadata cont3 --zone=europe-west3-c --keys=google-logging-enabled

I've tested this on a fresh VM witn ContainterOS 77 and didn't select "logging" when creating it. When I checked the service status with systemctl status stackdriver-logging.service it wasn't running.

Then I created another one with logging enabled and check service status - it was running as expected. Then I stopped the instance, removed the key, started instance and checked service status. It wasn't running (also as expeceted).

If for some reason you can't remove the key from metadata you can always try adding a startup script sudo systemctl disable --now stackdriver-logging.service.

Wojtek_B
  • 1,113
1

Try editing the the Custom metadata values. You should have two of them set as true (google-logging-enabled and google-monitoring-enabled). Set them to false and look into the instance to check if the other containers (Stackdriver related) are not running.