Amazon Linux2でrootでtd-agentを起動する

Amazon Linux2を使い /var/log/secure を転送したかったので、td-agentをインストールしてrootで起動できるように設定をいろいろ変更してみたのですが、一向にrootで起動せず。

sudo systemctl status td-agent.service

statusを見てみたところ

● td-agent.service - td-agent: Fluentd based data collector for Treasure Data
   Loaded: loaded (/usr/lib/systemd/system/td-agent.service; disabled; vendor preset: disabled)
   Active: active (running) since 木 2018-10-18 11:31:54 UTC; 10s ago
     Docs: https://docs.treasuredata.com/articles/td-agent
  Process: 18080 ExecStart=/opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td-agent/td-agent.pid $TD_AGENT_OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 18085 (fluentd)
   CGroup: /system.slice/td-agent.service
           ├─18085 /opt/td-agent/embedded/bin/ruby /opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td-agent/td-agent.pid
           └─18090 /opt/td-agent/embedded/bin/ruby -Eascii-8bit:ascii-8bit /opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td-agent/td-agent.pid --under-supervisor

10月 18 11:31:54 ip-10-0-1-247.ap-northeast-1.compute.internal systemd[1]: Starting td-agent: Fluentd based data collector for Treasure Data...
10月 18 11:31:54 ip-10-0-1-247.ap-northeast-1.compute.internal systemd[1]: Started td-agent: Fluentd based data collector for Treasure Data.
/usr/lib/systemd/system/td-agent.service

の設定ファイルが使われているようだったので、このファイル内の設定をrootに書き換えます

[Service]
User=td-agent
Group=td-agent

[Service]
User=root
Group=root

として

sudo systemctl daemon-reload
sudo systemctl restart td-agent.service

設定を読み込み直して再起動すると

root     18166  0.0  3.3 160492 32716 ?        Sl   11:33   0:00 /opt/td-agent/embedded/bin/ruby /opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td-agent/td-agent.pid
root     18171  0.1  4.5 195408 44252 ?        Sl   11:33   0:01 /opt/td-agent/embedded/bin/ruby -Eascii-8bit:ascii-8bit /opt/td-agent/embedded/bin/fluentd --log /var/log/td-agent/td-agent.log --daemon /var/run/td-agent/td-agent.pid --under-supervisor

rootで起動しました!