EKS ログコレクターでログを収集する方法を教えてください

2023.01.27

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

困っていた内容

EKS on EC2 に関する問い合わせでサポートに確認したところ「EKS ログコレクターで収集したログをご提供ください」と言われましたが、取得方法がわかりません。取得方法を教えてください。

どう対応すればいいの?

GitHub リポジトリのスクリプトを実行してください。

EKS ログコレクター(EKS Logs Collector)は、EKS のノード(EC2 インスタンス)で実行するスクリプトで、EKS および OS に関するログ・情報を収集します。収集したログは、1 つのファイルに圧縮およびアーカイブされるため、サポートにはこの作成されたアーカイブをご提供ください。

EKS ログコレクターは、Linux 用Windows 用の両方が提供されているため、環境にあわせてご利用ください。

サポートから追加の指示がある場合は、指示の内容を優先してください

Linux の場合

SSH や Session Manager 等でノードに接続します。

参考:SSH を使用した Linux インスタンスへの接続 - Amazon Elastic Compute Cloud

Amazon EKS ログ コレクタースクリプトをダウンロードします。

実行するコマンド

curl -O https://raw.githubusercontent.com/awslabs/amazon-eks-ami/master/log-collector-script/linux/eks-log-collector.sh

実行例

$ curl -O https://raw.githubusercontent.com/awslabs/amazon-eks-ami/master/log-collector-script/linux/eks-log-collector.sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 23891  100 23891    0     0  25053      0 --:--:-- --:--:-- --:--:-- 25069

書き込みエラー(Failure writing output to destination)が発生する場合は、書き込みが可能なディレクトリに移動するか、実行ユーザの権限を確認してください

スクリプトを実行してログを収集し、アーカイブを作成します。

実行するコマンド

sudo bash eks-log-collector.sh

実行例

$ sudo bash eks-log-collector.sh

	This is version 0.7.3. New versions can be found at https://github.com/awslabs/amazon-eks-ami/blob/master/log-collector-script/

Trying to collect common operating system logs... 
Trying to collect kernel logs... 
Trying to collect mount points and volume information... 
Trying to collect SELinux status... 
Trying to collect iptables information... 
Trying to collect installed packages... 
Trying to collect active system services... 
Trying to Collect Containerd daemon information...
Trying to Collect Containerd running information...
Trying to Collect Docker daemon information... 

	Warning: The Docker daemon is not running. 

Trying to collect kubelet information... 
Trying to collect L-IPAMD introspection information... Trying to collect L-IPAMD prometheus metrics... Trying to collect L-IPAMD checkpoint...
Trying to collect Multus logs if they exist... 
Trying to collect sysctls information... 
Trying to collect networking infomation... conntrack v1.4.4 (conntrack-tools): 1 flow entries have been shown.

Trying to collect CNI configuration information... 
Trying to collect Docker daemon logs... 
Trying to Collect sandbox-image daemon information... 
Trying to Collect CPU Throttled Process Information... 
Trying to Collect IO Throttled Process Information... 
Trying to archive gathered information... 

	Done... your bundled logs are located in /var/log/eks_i-1234567890abcdef0_2023-01-02_0304-UTC_0.7.3.tar.gz

/var/log/以下に tar.gz ファイルが作成されます。サポートにはこの作成されたファイルを提供します。

Windows の場合

RDP や Session Manager 等でノードに接続します。

参考:Windows インスタンスに接続する - Amazon Elastic Compute Cloud

Amazon EKS ログ コレクタースクリプトをダウンロードします。

実行するコマンド

Invoke-WebRequest -OutFile eks-log-collector.ps1 https://raw.githubusercontent.com/awslabs/amazon-eks-ami/master/log-collector-script/windows/eks-log-collector.ps1

実行例

PS C:\Users\Administrator> Invoke-WebRequest -OutFile eks-log-collector.ps1 https://raw.githubusercontent.com/awslabs/amazon-eks-ami/master/log-collector-script/windows/eks-log-collector.ps1

スクリプトを実行してログを収集し、アーカイブを作成します。

実行するコマンド

.\eks-log-collector.ps1

実行例

PS C:\Users\Administrator> .\eks-log-collector.ps1
Running Default(Collect) Mode
Cleaning up directory
OK
Creating temporary directory
OK
Collecting System information
OK
Checking free disk space
C: drive has 64% free space
OK
Collecting System Logs
OK
Collecting Application Logs
OK
Collecting Volume info
OK
Collecting Windows Firewall info
Collecting Rules for Domain profile
Collecting Rules for Private profile
Collecting Rules for Public profile
OK
Collecting installed applications list
OK
Collecting Services list
OK
Collecting Docker daemon information
Checking status of service: docker
Service docker is running.
OK
Collecting Containerd information
Checking status of service: containerd
Service containerd is running.
OK
Collecting Kubelet logs
OK
Collecting Kube-proxy logs
OK
Collecting kubelet information
OK
Collecting Docker daemon logs
OK
Collecting EKS logs
OK
Collecting network Information
OK
Archiving gathered data
Done... your bundled logs are located in  C:\log-collector\eks_i-1234567890abcdef0_20230102T0304567890Z.zip

C:\log-collector以下に zip ファイルが作成されます。サポートにはこの作成されたファイルを提供します。

参考資料