amazon-cloudwatch-agent icon indicating copy to clipboard operation
amazon-cloudwatch-agent copied to clipboard

Supporting enabling omit_hostname for statsd but disabled for collectd,disk and mem

Open rpatidar opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. As of now its looks like omit_hostname is a global config and it causes the host metrics to be removed from all other fields as well.

  1. My simple requirements is to use statsd in the orignal form without adding any new dimension of host
  2. I want to generate adittional metrics which are published by collectd and disk but also aggregated by some dimension of aws asg group , instance types.

as of now doing both together does not work well for me.

Describe the solution you'd like Support the configuration at child level ?

Describe alternatives you've considered Moving to telegraf probably

Additional context

Here is my configuration that does not work well

{
  "agent": {
    "metrics_collection_interval": 10,
    "run_as_user": "root",
    "omit_hostname" : true
  },
  "metrics": {
    "metrics_collected": {
      "statsd":{
        "service_address":":8125",
        "metrics_collection_interval":10,
        "metrics_aggregation_interval":60
      },
      "collectd": {
        "metrics_aggregation_interval": 10
      },
      "disk": {
        "measurement": [
          "used_percent"
        ],
        "metrics_collection_interval": 10,
        "resources": [
          "/"
        ]
      },
      "mem": {
        "measurement": [
          "mem_used_percent"
        ],
        "metrics_collection_interval": 10
      }
    }
  },
  "logs": {
    "logs_collected": {
      "files": {
        "collect_list": [
          {
            "file_path": "/home/ubuntu/logs/app.log",
            "log_group_name": "/aws/ec2/application",
            "log_stream_name": "{instance_id}"
          }
        ]
      }
    }
  }
}

rpatidar avatar Oct 12 '24 14:10 rpatidar

Below workarounds is solving most of the problem i had , added following dimension and also add a Sed command to replace the tokens

      "disk": {
        "append_dimensions": {
          "AutoScalingGroupName" : "AUTOSCALING_GROUP_NAME",
          "InstanceType" : "INSTANCE_TYPE",
          "InstanceId": "INSTANCE_ID"
        },
        "measurement": [
          "used_percent"
        ],
        "metrics_collection_interval": 10,
        "resources": [
          "/"
        ]
      },

and

sudo sed -i "s/INSTANCE_ID/${INSTANCE_ID}/g;s/AUTOSCALING_GROUP_NAME/${AUTOSCALING_GROUP_NAME}/g;s/INSTANCE_TYPE/${INSTANCE_TYPE}/g;" /home/ubuntu/config.json

rpatidar avatar Oct 12 '24 15:10 rpatidar