Reputation: 2021
I'm trying to install cw agent on my eks cluster to get instance level metrics, especially mem_used_percent metric, can someone point me where i'm wrong, i've the cwagent server policy attached to the eks nodes.
I'm seeing all container insights metrics but not able to see any metrics in cw agent(aws console).
What am i missing here?
my config_file
apiVersion: v1
data:
# Configuration is in Json format. No matter what configure change you make,
# please keep the Json blob valid.
cwagentconfig.json: |
{
"logs": {
"metrics_collected": {
"kubernetes": {
"cluster_name": "xxxx",
"metrics_collection_interval": 60
},
"mem": {
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60
}
},
"force_flush_interval": 5
}
}
kind: ConfigMap
metadata:
name: cwagentconfig
namespace: amazon-cloudwatch
Image: amazon/cloudwatch-agent:1.247348.0b251302 CI_VERSION: "k8s/1.3.7"
kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.1", GitCommit:"d647ddbd755faf07169599a625faf302ffc34458", GitTreeState:"clean", BuildDate:"2019-10-02T23:49:20Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.9-eks-d1db3c", GitCommit:"d1db3c46e55f95d6a7d3e5578689371318f95ff9", GitTreeState:"clean", BuildDate:"2020-10-20T22:18:07Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}
My_logs:
2021/07/02 23:49:06 I! I! Detected the instance is EC2
2021/07/02 23:49:03 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/bin/default_linux_config.json ...
/opt/aws/amazon-cloudwatch-agent/bin/default_linux_config.json does not exist or cannot read. Skipping it.
2021/07/02 23:49:03 Reading json config file path: /etc/cwagentconfig/..2021_07_02_23_48_59.690305669/cwagentconfig.json ...
2021/07/02 23:49:03 Find symbolic link /etc/cwagentconfig/..data
2021/07/02 23:49:03 Find symbolic link /etc/cwagentconfig/cwagentconfig.json
2021/07/02 23:49:03 Reading json config file path: /etc/cwagentconfig/cwagentconfig.json ...
Valid Json input schema.
2021/07/02 23:49:03 I! attempt to access ECS task metadata to determine whether I'm running in ECS.
2021/07/02 23:49:04 W! retry [0/3], unable to get http response from http://169.254.170.2/v2/metadata, error: unable to get response from http://169.254.170.2/v2/metadata, error: Get "http://169.254.170.2/v2/metadata": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021/07/02 23:49:05 W! retry [1/3], unable to get http response from http://169.254.170.2/v2/metadata, error: unable to get response from http://169.254.170.2/v2/metadata, error: Get "http://169.254.170.2/v2/metadata": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021/07/02 23:49:06 W! retry [2/3], unable to get http response from http://169.254.170.2/v2/metadata, error: unable to get response from http://169.254.170.2/v2/metadata, error: Get "http://169.254.170.2/v2/metadata": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021/07/02 23:49:06 I! access ECS task metadata fail with response unable to get response from http://169.254.170.2/v2/metadata, error: Get "http://169.254.170.2/v2/metadata": context deadline exceeded (Client.Timeout exceeded while awaiting headers), assuming I'm not running in ECS.
No csm configuration found.
No metric configuration found.
Configuration validation first phase succeeded
2021/07/02 23:49:06 I! Config has been translated into TOML /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml
2021-07-02T23:49:06Z I! Starting AmazonCloudWatchAgent 1.247348.0
2021-07-02T23:49:06Z I! Loaded inputs: cadvisor k8sapiserver
2021-07-02T23:49:06Z I! Loaded aggregators:
2021-07-02T23:49:06Z I! Loaded processors: ec2tagger k8sdecorator
2021-07-02T23:49:06Z I! Loaded outputs: cloudwatchlogs
2021-07-02T23:49:06Z I! Tags enabled:
2021-07-02T23:49:06Z I! [agent] Config: Interval:1m0s, Quiet:false, Hostname:"ip-10-182-7-7.ec2.internal", Flush Interval:1s
2021-07-02T23:49:06Z I! [logagent] starting
2021-07-02T23:49:06Z I! [logagent] found plugin cloudwatchlogs is a log backend
Upvotes: 1
Views: 837
Reputation: 19
Metrics collection such as memory usage needs to be put in the metrics
section of the json file instead of in the logs
section. Explained in the aws doco. You just need to rename the first section, and I think you have an extra }
at the end.
The following should work:
"metrics": {
"metrics_collected": {
"kubernetes": {
"cluster_name": "xxxx",
"metrics_collection_interval": 60
},
"mem": {
"measurement": [
"mem_used_percent"
],
"metrics_collection_interval": 60
}
},
"force_flush_interval": 5
}
Upvotes: 0