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

Additional prop support added for all metrics.

Open musa-asad opened this issue 1 year ago • 2 comments

Description of the issue

Public docs state that the drop_original_metrics feature is supported, but, when we try to run it, the config translation states it isn't allowed: Under path : /metrics/metrics_collected/statsd | Error : Additional property drop_original_metrics is not allowed.

Description of changes

I allow drop_original_metrics for the statsd metric as well as other metrics that didn't have it (collectd and ethtool) and adjusted the CW exporter translator code to allow for this.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

I first replicated the issue and then tried running CWAgent with the following config:

{
    "metrics": {
        "aggregation_dimensions": [
            ["InstanceId"]
        ],
        "metrics_collected": {
            "statsd": {
                "service_address": ":8125",
		"metrics_collection_interval": 10,
                "metrics_aggregation_interval": 50,
		"drop_original_metrics": ["should_drop_24"]
            }
        }
    }
}

The relevant errors are as follows (when we try using drop_original_metrics for all metrics collected):

Under path : /metrics/metrics_collected/ethtool | Error : Additional property drop_original_metrics is not allowed
Under path : /metrics/metrics_collected/collectd | Error : Additional property drop_original_metrics is not allowed
Under path : /metrics/metrics_collected/statsd | Error : Additional property drop_original_metrics is not allowed

After that, I re-ran the configuration and the error didn't persist.

Then, I ran echo "should_drop_24:123|c" | nc -u -w1 127.0.0.1 8125 and echo "should_not_drop_24:123|c" | nc -u -w1 127.0.0.1 8125.

As expected, the should_drop_24 didn't show up in the CW console, but should_not_drop_24 did. Screenshot 2024-06-24 at 11 55 42 AM

We also see this in the yaml file:

exporters:
    awscloudwatch:
        drop_original_metrics:
            should_drop_24: true

collectd It didn't emit drop_cpu_value. Screenshot 2024-07-03 at 1 40 12 PM

ethtool It stopped emitting the metric when it was added to drop_original_metrics. Screenshot 2024-07-03 at 1 38 11 PM

Additionally, I updated the unit tests to accommodate the changes made in this CR.

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make lint

musa-asad avatar Jun 07 '24 21:06 musa-asad

This PR was marked stale due to lack of activity.

github-actions[bot] avatar Jun 18 '24 00:06 github-actions[bot]

Mind adding a screenshot of what the metrics look like in CW console? I would have expected an append_dimensions for the InstanceId so Im curious how it worked without that.

sky333999 avatar Jun 24 '24 14:06 sky333999

Will this parameter still drop metrics even if the aggregation_dimensions parameter is not being used ?

mitali-salvi avatar Jul 05 '24 15:07 mitali-salvi

Will this parameter still drop metrics even if the aggregation_dimensions parameter is not being used ?

Yeah, it will still drop those metrics.

musa-asad avatar Jul 08 '24 12:07 musa-asad