AWSにAmazonlinux2のインスタンスを構築して
オンプレのネットワーク機器に対してcollectd-snmpで情報収集を行い
CloudWatchに連携検討しています。
CloudWatchのメトリックス
すべて-collectd-Host,PluginInstancenを確認したところ、Host部分にsnmp.confのHostの設定ではなくインスタンス名が表示されてしまいます。
ここにsnmp.confのHostの設定を表示させるにはどのようにすればよいかご協力をお願い致します。
/etc/collectd.d/snmp.confの設定
LoadPlugin snmp <Plugin snmp> <Data "uptime"> Type "uptime" Table false Instance "" Values "DISMAN-EVENT-MIB::sysUpTimeInstance" </Data> <Data "std_traffic"> Type "if_octets" Table true Instance "IF-MIB::ifDescr" Values "IF-MIB::ifInOctets" "IF-MIB::ifOutOctets" </Data> <Host "net-01"> Address "192.168.2.XXX" Version 2 Community "SysSNMP" Collect "uptime" "std_traffic" Interval 60 </Host> <Host "net-02"> Address "192.168.2.XXX" Version 2 Community "SysSNMP" Collect "uptime" "std_traffic" Interval 60 </Host> <Host "com-01"> Address "192.168.1.XXX" Version 2 Community "SysSNMP" Collect "uptime" "std_traffic" Interval 60 </Host> </Plugin>
【追記】
ここまでの手順とCloudWatch Agentの設定ファイルの内容を記載します。
0. CloudWatch用ロールの作成
AmazonEC2RoleforSSM
CloudWatchAgentAdminPolicy
CloudWatchAgentServerPolicy
0. EC2構築(Amazonlinux2)ロール割り当て
0. CloudWatch Agentのインストール
sudo yum install amazon-cloudwatch-agent
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
0. collectdのインストール
sudo yum install -y collectd
sudo yum install -y collectd-snmp
0. collectd の CloudWatch 用プラグインをインストール
git clone https://github.com/awslabs/collectd-cloudwatch.git
cd collectd-cloudwatch/src
sudo ./setup.py
- /etc/collectd.d/snmp.confの設定(上記内容)
- CloudWatch でメトリクス確認(ネットワーク機器が表示できない)←いまここ
● /opt/collectd-plugins/cloudwatch/config/plugin.conf の設定
# The path to the AWS credentials file. This value has to be provided if plugin is used outside of EC2 instances #credentials_path = "/home/user/.aws/credentials" # The target region which will be used to publish metric data # For list of valid regions visit: http://docs.aws.amazon.com/general/latest/gr/rande.html#cw_region #region = "us-west-1" # The host parameter can be used to override instance-id or host information published with every metric #host = "Server1" # The pass through option allows unsafe regexes such as '.*' or '.+'. # WARNING: ENABLING THIS OPTION MAY LEAD TO PUBLISHING A LARGE NUMBER OF METRICS # SEE https://aws.amazon.com/cloudwatch/pricing/ TO UNDERSTAND HOW TO ESTIMATE YOUR BILL. whitelist_pass_through = False # The debug parameter enables verbose logging of published metrics debug = False # Wheter or not to push the ASG as part of the dimension. # WARNING: ENABLING THIS WILL LEAD TO CREATING A LARGE NUMBER OF METRICS. push_asg = False # Whether or not to push the constant value to CWM as a metric push_constant = False # Constant dimension value to add to CWL constant_dimension_value = "ALL" # The proxy_server_name is used for connecting *.amazonaws.com, to put metrics. #proxy_server_name = http://myproxyserver.com # The proxy_server_port is used for connecting *.amazonaws.com, to put metrics. #proxy_server_port = 8080 # The storage resolution is for high resolution support, it shows the resolution of storage, the unit is second #enable_high_resolution_metrics = False # The flush_interval_in_seconds is used for flush interval, it means how long plugin should flush the metrics to Cloudwatch, the unit here is second #flush_interval_in_seconds = 60
●CloudWatch Agentの設定ファイル(SSM パラメータストアに保存)
ファイル名:AmazonCloudWatch-linux { "agent": { "metrics_collection_interval": 60, "run_as_user": "root" }, "logs": { "logs_collected": { "files": { "collect_list": [ { "file_path": "/var/log/messages", "log_group_name": "messages", "log_stream_name": "{instance_id}" } ] } } }, "metrics": { "metrics_collected": { "collectd": { "metrics_aggregation_interval": 60 }, "cpu": { "measurement": [ "cpu_usage_idle" ], "metrics_collection_interval": 60, "resources": [ "*" ], "totalcpu": true }, "disk": { "measurement": [ "used_percent" ], "metrics_collection_interval": 60, "resources": [ "*" ] }, "diskio": { "measurement": [ "write_bytes", "read_bytes", "writes", "reads" ], "metrics_collection_interval": 60, "resources": [ "*" ] }, "mem": { "measurement": [ "mem_used_percent" ], "metrics_collection_interval": 60 }, "net": { "measurement": [ "bytes_sent", "bytes_recv", "packets_sent", "packets_recv" ], "metrics_collection_interval": 60, "resources": [ "*" ] }, "statsd": { "metrics_aggregation_interval": 60, "metrics_collection_interval": 10, "service_address": ":8125" }, "swap": { "measurement": [ "swap_used_percent" ], "metrics_collection_interval": 60 } } } }
あなたの回答
tips
プレビュー