sj26/sidekiq-cloudwatchmetrics

The parameter MetricData.member.12.Dimensions.member.1.Value is required. (Aws::CloudWatch::Errors::MissingParameter)

taimoordev opened this issue · 2 comments

Hey @sj26
I have following gems
sidekiq-cloudwatchmetrics (2.6.0)
sidekiq (7.2.0, 7.0.7, 6.4.2)
aws-sdk-cloudwatch (1.81.0, 1.67.0)

and I get the following error on the CloudWatch console.

53
2023-11-01T16:36:01.871-07:00
#<Thread:0x00007f5f4f1d1b30@cloudwatch metrics publisher /usr/local/bundle/gems/sidekiq-6.4.2/lib/sidekiq/util.rb:63 run> terminated with exception (report_on_exception is true):
54
2023-11-01T16:36:01.871-07:00
/usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/seahorse/client/plugins/raise_response_errors.rb:17:in `call': The parameter MetricData.member.12.Dimensions.member.1.Value is required. (Aws::CloudWatch::Errors::MissingParameter)
55
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/aws-sdk-core/plugins/checksum_algorithm.rb:111:in `call'
56
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/aws-sdk-core/plugins/jsonvalue_converter.rb:22:in `call'
57
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/aws-sdk-core/plugins/idempotency_token.rb:19:in `call'
58
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/aws-sdk-core/plugins/param_converter.rb:26:in `call'
59
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/seahorse/client/plugins/request_callback.rb:71:in `call'
60
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/aws-sdk-core/plugins/response_paging.rb:12:in `call'
61
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/seahorse/client/plugins/response_target.rb:24:in `call'
62
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-core-3.131.1/lib/seahorse/client/request.rb:72:in `send_request'
63
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/aws-sdk-cloudwatch-1.67.0/lib/aws-sdk-cloudwatch/client.rb:3365:in `put_metric_data'
64
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/sidekiq-cloudwatchmetrics-2.6.0/lib/sidekiq/cloudwatchmetrics.rb:235:in `block in publish'
65
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/sidekiq-cloudwatchmetrics-2.6.0/lib/sidekiq/cloudwatchmetrics.rb:234:in `each'
66
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/sidekiq-cloudwatchmetrics-2.6.0/lib/sidekiq/cloudwatchmetrics.rb:234:in `each_slice'
67
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/sidekiq-cloudwatchmetrics-2.6.0/lib/sidekiq/cloudwatchmetrics.rb:234:in `publish'
68
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/sidekiq-cloudwatchmetrics-2.6.0/lib/sidekiq/cloudwatchmetrics.rb:77:in `run'
69
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/sidekiq-6.4.2/lib/sidekiq/util.rb:56:in `watchdog'
70
2023-11-01T16:36:01.871-07:00
from /usr/local/bundle/gems/sidekiq-6.4.2/lib/sidekiq/util.rb:65:in `block in safe_thread'
image

@sj26 I suspect that these loops don't have guard statement, and these might be sending dimension value as nil
The parameter MetricData.member.12.Dimensions.member.1.Value is required. (Aws::CloudWatch::Errors::MissingParameter)
image

according to aws-sdk-cloudwatch doc, dimenstion is optional but for objects inside it, value and name must be present
official doc reference
image

@sj26 I found out the issue lies here
image

!!'' == true as empty string evaluates to true, that is why this dimension object contains blank value in it for tag.

Solution
add unless process['tag'].empty? check