Negative value for custom metric
Is your feature request related to a problem? Please describe. I'm using amazon-cloudwatch-agent for putting custom metrics from the application and was badly surprised when tried to push negative value for gauge type because it does not support:
2023-04-19T11:35:21Z W! error: negative value, metric service.metric.seconds, value -0.9775779816513761
2023-04-19T11:44:30Z W! error: negative value, metric service.metric.seconds, value -0.9775779816513761
Describe the solution you'd like Add supporting negative values for custom metrics.
Describe alternatives you've considered aws cli did it well:
aws cloudwatch put-metric-data --region ap-northeast-1 --metric-name CustomTestMetric --namespace MyService --value -5 --timestamp 2023-04-19T15:00:02.000Z
Additional context
How are you publishing the custom metric? Is it via statsd? The way that we handle client-side aggregation, we assume that metric values are >= 0. https://github.com/aws/amazon-cloudwatch-agent/blob/2dd89abaab4590cffbbc31ef89319b62809b09d1/metric/distribution/regular/regular_distribution.go#L125-L127 I think that this would need to be overhauled to support negative values.
I just discovered this and it's ruined my whole day :(
+1 for fixing this, as negative values for metrics are totally legitimate and should be supported.