CloudWatch input plugin not working with EC2 namespace

Hello,

When I ran Logstash 8.6.2 version to collect EC2 CloudWatch metrics, the process returned "Exception: NameError".
As far as I know by testing, this exception happends only for AWS/EC2 namespace, and setting for other namespace such as AWS/RDS works.
Logstash 7.17.9 worked with the same config file.

My issue seems the same as this post, but it was already closed without any comments.

Any suggestions would be greatly appreciated.

Input configuration:

input {
  cloudwatch {
    namespace => "AWS/EC2"
    metrics => [ "CPUUtilization" ]
    filters => { "tag:AutoStop"=> "false"}
    region => "ap-northeast-1"
  }
}

Error message:

[2023-03-30T12:29:19,453][ERROR][logstash.javapipeline    ][main][8624b06bdbedde7950dc9a8f04c94d2da6a631699d3e08a2ee9034935b12428b] A plugin had an unrecoverable error. Will restart this plugin.
  Pipeline_id:main
  Plugin: <LogStash::Inputs::CloudWatch namespace=>"AWS/EC2", metrics=>["CPUUtilization"], id=>"8624b06bdbedde7950dc9a8f04c94d2da6a631699d3e08a2ee9034935b12428b", region=>"ap-northeast-1", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_177ff1f1-f27e-4aa3-95a5-ec3036638fa2", enable_metric=>true, charset=>"UTF-8">, role_session_name=>"logstash", statistics=>["SampleCount", "Average", "Minimum", "Maximum", "Sum"], interval=>900, period=>300, combined=>false>
  Error: uninitialized constant Aws::EC2
  Exception: NameError
  Stack: org/jruby/RubyModule.java:3963:in `const_missing'
org/jruby/RubyModule.java:3905:in `const_get'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.1/lib/logstash/inputs/cloudwatch.rb:247:in `block in clients'
org/jruby/RubyHash.java:794:in `default'
org/jruby/RubyHash.java:1265:in `[]'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.1/lib/logstash/inputs/cloudwatch.rb:316:in `resources'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.1/lib/logstash/inputs/cloudwatch.rb:179:in `from_resources'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.1/lib/logstash/inputs/cloudwatch.rb:160:in `block in run'
org/jruby/RubyArray.java:1865:in `each'
/usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.1/lib/logstash/inputs/cloudwatch.rb:157:in `run'
/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:411:in `inputworker'
/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:402:in `block in start_input'

Thank you.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.