【New Relic】AmazonLinux2023(arm)に対するinfrastructure agentのログ監視について

記事タイトルとURLをコピーする

みなさんこんにちは。
マネージドサービス部の福田です。

以前AmazonLinux2023(arm)においてinfrastructure agentを使用した
ログ転送が上手くいかなかったので対応方法を記載します。

NewRelic infrastructure agentのインストール

NewRelic infrastructure agentはFluent-bitを使用した
ログ転送機能がありinfrastructure agentインストール時に
Logs Integrationとしてログ転送機能がインストールされます。

しかしAmazonLinux2023(arm)の場合はLogs Integrationはインストールされません。
公式ドキュメントを確認すると以下記載があり、AmazonLinux2023(arm)はサポートされていないようです。

Forward your logs using the infrastructure agent | New Relic Documentation

Amazon Linux 2 and 2023 (ARM64 not supported for 2023)

AmazonLinux2023(x86_64)のinfrastructure agentインストール結果
~~~略~~~
Installed:
  fluent-bit-2.0.8-1.x86_64
  libpq-15.0-2.amzn2023.0.1.x86_64
  newrelic-infra-1.42.5-1.amazonlinux-2023.x86_64

~~~略~~~
  --------------------
  Installation Summary

  −  Golden Signal Alerts  (skipped)
  ✔  Infrastructure Agent  (installed)
  ✔  Logs Integration  (installed)


  -------------------
 
AmazonLinux2023(arm64)のinfrastructure agentインストール結果
~~~略~~~
Installed:
  newrelic-infra-1.43.2-1.amazonlinux-2023.aarch64
~~~略~~~
  --------------------
  Installation Summary

  −  Golden Signal Alerts  (skipped)
  ✔  Infrastructure Agent  (installed)

  --------------------

infrastructure agent経由でNewRelicへログ転送されるか

結論から言うとAmazonLinux2023(arm)の場合
infrastructure agentインストールしただけではNewRelicへログを転送することはできません。

しかしinfrastructure agentインストール後に
/var/db/newrelic-infra/newrelic-integrations/logging/に
以下Fluent Bit Pluginは存在しておりました。
(Fluent Bit Pluginの詳細は公式ドキュメントを参照)

-rw-r--r--. 1 root root 9335272 Jul 13 07:53 out_newrelic.so
-rw-r--r--. 1 root root     909 Jul 13 07:53 parsers.conf

なのでFluent Bit を手動でインストールすると
どのように挙動が変化するのか確認しました。

Fluent bitインストール

  • 公式ページから Fluent bitのインストールコマンドを確認する

Amazon Linux docs.fluentbit.io

コマンド実行例
$ curl https://raw.githubusercontent.com/fluent/fluent-bit/master/install.sh | sh                                                                                                                                                                                                                   stall.sh | sh
~~~略~~~
Installed:
  fluent-bit-2.1.7-1.aarch64                      libpq-15.0-2.amzn2023.0.1.aarch64

Complete!

Installation completed. Happy Logging!
  • fluent-bitを起動する
$ sudo systemctl start fluent-bit
  • fluent-bitのステータス確認
    Active: activeになっていることを確認します。
$ systemctl status fluent-bit

● fluent-bit.service - Fluent Bit
     Loaded: loaded (/usr/lib/systemd/system/fluent-bit.service; enabled; preset: disabled)
     Active: active (running) since Fri 2023-07-14 06:42:26 UTC; 1h 12min ago
       Docs: https://docs.fluentbit.io/manual/
   Main PID: 3036 (fluent-bit)
      Tasks: 4 (limit: 2131)
     Memory: 2.1M
        CPU: 1.745s
     CGroup: /system.slice/fluent-bit.service
             mq3036 /opt/fluent-bit/bin/fluent-bit -c //etc/fluent-bit/fluent-bit.conf

Fluent bit経由でNewRelicへログが転送されるか確認

以下のログ情報がNewRelicに転送されたことが確認できました。

{
  "agentName": "Infrastructure",
  "agentVersion": "1.43.2",
  "aws.accountId": "xxxxxxxxxxx",
  "aws.arn": "arn:aws:ec2:ap-northeast-1:xxxxxxxxxxxxxxxx:instance/xxxxxxxxxxxx",
  "aws.awsAvailabilityZone": "ap-northeast-1a",
  "aws.awsRegion": "ap-northeast-1",
  "aws.ec2AmiId": "xxxxxxxxxxxxxxxx",
  "aws.ec2Architecture": "arm64",
  "aws.ec2EbsOptimized": "true",
  "aws.ec2Hypervisor": "xen",
  "aws.ec2InstanceId": "xxxxxxxxxxxx",
  "aws.ec2InstanceType": "t4g.small",
  "aws.ec2KeyName": "test-newrelic",
  "aws.ec2PlacementGroupTenancy": "default",
  "aws.ec2PrivateDnsName": "ip-xxxxxxxxxxxxxx.ap-northeast-1.compute.internal",
  "aws.ec2PrivateIpAddress": "xxxxxxxxxxxx",
  "aws.ec2PublicDnsName": "ec2-xxxxxxxxxxxx.ap-northeast-1.compute.amazonaws.com",
  "aws.ec2PublicIpAddress": "xxxxxxxxxxxx",
  "aws.ec2RootDeviceName": "/dev/xvda",
  "aws.ec2RootDeviceType": "ebs",
  "aws.ec2State": "running",
  "aws.ec2SubnetId": "subnet-xxxxxxxxxxxx",
  "aws.ec2VirtualizationType": "hvm",
  "aws.ec2VpcId": "vpc-xxxxxxxxxxxx",
  "coreCount": "2",
  "entity.guid.INFRA": "MzY4ODEyMHxJTkZSQXxOQXwtMzk2Mzg0OTc5OTkzODIwNDE1MQ",
  "entity.guids": "MzY4ODEyMHxJTkZSQXxOQXwtMzk2Mzg0OTc5OTkzODIwNDE1MQ",
  "fb.input": "tail",
  "filePath": "/etc/test.log",
  "fullHostname": "ip-xxxxxxxxxxxx.ap-northeast-1.compute.internal",
  "hostname": "ip-xxxxxxxxxxxx.ap-northeast-1.compute.internal",
  "hostStatus": "running",
  "instanceType": "t4g.small",
  "kernelVersion": "6.1.34-59.116.amzn2023.aarch64",
  "label.Name": "Amazon-Linux-2023_arm",
  "linuxDistribution": "Amazon Linux 2023",
  "logtype": "newrelic-cli",
  "message": "20220928 serverworks test swx-test.log:ERROR",
  "newrelic-cli": "true",
  "newrelic.logPattern": "nr.DID_NOT_MATCH",
  "newrelic.source": "api.logs",
  "nr_deployed_by": "newrelic-cli",
  "operatingSystem": "linux",
  "plugin.source": "BARE-METAL",
  "plugin.type": "nri-agent",
  "plugin.version": "1.17.1",
  "processorCount": "2",
  "providerAccountId": "xxxxxx",
  "providerAccountName": "xxxx",
  "systemMemoryBytes": "1946554368",
  "timestamp": 1689316270696
}

おまけ

Fluentbitインストール前でも存在していたNewRelicのFluent Bit Pluginは
Fluentbitをインストールすると勝手に動いておりました。

#Fluentbitインストール前
ps auxf | egrep "td-agent-bit|newrelic"
ec2-user    2323  0.0  0.0 222104  1708 pts/0    S+   00:40   0:00              \_ grep -E --color=auto td-agent-bi |newrelic
root        2070  0.0  0.3 717340  5908 ?        Ssl  00:39   0:00 /usr/bin/newrelic-infra-service
root        2077  0.3  1.9 739192 37184 ?        Sl   00:39   0:00  \_ /usr/bin/newrelic-infra
#Fluentbitインストール後
ps auxf | egrep "td-agent-bit|newrelic"
ec2-user    3975  0.0  0.0 222104  1708 pts/0    S+   00:52   0:00              \_ grep -E --color=auto td-agent-bi |newrelic
root        3890  0.0  0.3 717340  5908 ?        Ssl  00:52   0:00 /usr/bin/newrelic-infra-service
root        3896  2.6  1.7 739192 33320 ?        Sl   00:52   0:00  \_ /usr/bin/newrelic-infra
root        3965  1.5  1.1 850792 22516 ?        Sl   00:52   0:00      \_ /opt/fluent-bit/bin/fluent-bit -c /tmp/fb/nr_fb_config2543269170 -e /var/db/newrelic-infra/newrelic-integrations/logging/out_newrelic.so -R /var/db/newrelic-infra/newrelic-integrations/logging/parsers.conf

まとめ

現時点(2023年10月10日時点)でAmazonLinux2023(arm)に対して
infrastructure agentのログ転送機能はサポートされておりません。
今後サポート予定らしいですがそれまでは手動でFluentbitをインストールする必要がありそうです。

福田 圭 (記事一覧)

マネージドサービス部

2023 New Relic Partner Trailblazer