過去の記事でご紹介する設定ファイルのサンプルとエージェントの起動方法を使用して、別のサーバーで再利用した際にエラーとなりました。以前は、Windows Server 2012 R2 にて実績がありましたが、今回はWindows Server 2016 となります。
PowerShell で出力されたエラーは、「Invalid json format, please check. Reason: invalid character ‘i’ looking for beginning of value」となります。過去の経験より、設定ファイルの記述に問題があると推測しました。
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.
PS C:\Windows\system32> cd "C:\Program Files\Amazon\AmazonCloudWatchAgent"
PS C:\Program Files\Amazon\AmazonCloudWatchAgent> ./amazon-cloudwatch-agent-ctl.ps1 -a fetch-config -m ec2 -c file:config.json
Successfully fetched the config and saved in C:\ProgramData\Amazon\AmazonCloudWatchAgent\Configs\file_config.json.tmp
Start configuration validation...
2019/09/25 16:13:37 Reading json config file path: C:\ProgramData\Amazon\AmazonCloudWatchAgent\Configs\file_config.json.tmp ...
2019/09/25 16:13:37 Invalid json format, please check. Reason: invalid character 'i' looking for beginning of value
2019/09/25 16:13:37 I! AmazonCloudWatchAgent Version 1.227496.0.
2019/09/25 16:13:37 Configuration validation first phase failed. Agent version: 1.227496.0. Verify the JSON input is only using features supported by this version.
PS C:\Program Files\Amazon\AmazonCloudWatchAgent> ./amazon-cloudwatch-agent-ctl.ps1 -a start
amazon-cloudwatch-agent is not configured. Applying default configuration before starting it.
Successfully fetched the config and saved in C:\ProgramData\Amazon\AmazonCloudWatchAgent\Configs\default.tmp
Start configuration validation...
2019/09/25 16:14:52 Reading json config file path: C:\ProgramData\Amazon\AmazonCloudWatchAgent\Configs\default.tmp ...
Valid Json input schema.
No csm configuration found.
No log configuration found.
Configuration validation first phase succeeded
Configuration validation second phase succeeded
Configuration validation succeeded