# Problems with cloudwatch input plugin - namespace AWS/EC2 NameError

**URL:** <https://discuss.elastic.co/t/problems-with-cloudwatch-input-plugin-namespace-aws-ec2-nameerror/326297>\
**Category:** Logstash\
**Created:** [February 23, 2023, 10:27am UTC](https://discuss.elastic.co/t/problems-with-cloudwatch-input-plugin-namespace-aws-ec2-nameerror/326297 "2023-02-23T10:27:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wodnd6646](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wodnd6646/32/117643_2.png) [@wodnd6646](https://discuss.elastic.co/u/wodnd6646)\
**Post date:** [February 23, 2023, 10:27am UTC](https://discuss.elastic.co/t/problems-with-cloudwatch-input-plugin-namespace-aws-ec2-nameerror/326297/1 "2023-02-23T10:27:27Z")

</div>

Hello All,  
problem summary: logstash can't recognize 'AWS/EC2'

I am setting up a logstash configuration file to get cloudwatch(EC2, RDS) data.  
I have written input plugin code as below, and RDS is working as I expected.  
However, EC2 part isn't working with error.  
I have no idea why NameError occurs only on EC2, even though it works fine on RDS.  
It seems that transpiled code 'Aws::EC2' is not recognized by jruby.  
How can I fix this error?

any suggestions would be grateful.  
thanks for your time.

- logstash.conf file code - input part

```auto
cloudwatch {
        namespace => "AWS/EC2"
        metrics => ["CPUUtilization"]
        filters => {
            InstanceId => "i-02fa5b2c465c1f89c"
        }
        region => "ap-northeast-2"
        access_key_id => "..."
        secret_access_key => "..."
    }

cloudwatch {
        namespace => "AWS/RDS"
        metrics => ["CPUUtilization", "FreeStorageSpace"]
        filters => {
            EngineName => "mysql"
        }
        region => "ap-northeast-2"
        access_key_id => "..."
        secret_access_key => "..."
    }

```

- error

```auto
2023-02-23 18:05:02 Pipeline_id:main
2023-02-23 18:05:02 Plugin: <LogStash::Inputs::CloudWatch access_key_id=>"AKIA3SX2Y7YUXPMSEP7B", namespace=>"AWS/EC2", secret_access_key=><password>, metrics=>["CPUUtilization"], filters=>{"InstanceId"=>"i-02fa5b2c465c1f89c"}, id=>"2ef442e73669393d64dca610d218d966d3ce2bda88f9b05d28491f8b52a8bf03", region=>"ap-northeast-2", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_f0001a8e-bd15-4a41-bd08-efeb34db5b46", enable_metric=>true, charset=>"UTF-8">, role_session_name=>"logstash", statistics=>["SampleCount", "Average", "Minimum", "Maximum", "Sum"], interval=>900, period=>300, combined=>false>
2023-02-23 18:05:01 Error: uninitialized constant Aws::EC2
2023-02-23 18:05:01 Exception: NameError
2023-02-23 18:05:01 Stack: org/jruby/RubyModule.java:3947:in `const_missing'
2023-02-23 18:05:01 org/jruby/RubyModule.java:3889:in `const_get'
2023-02-23 18:05:01 /usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.0/lib/logstash/inputs/cloudwatch.rb:247:in `block in clients'
2023-02-23 18:05:01 org/jruby/RubyHash.java:794:in `default'
2023-02-23 18:05:01 org/jruby/RubyHash.java:1265:in `[]'
2023-02-23 18:05:01 /usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.0/lib/logstash/inputs/cloudwatch.rb:316:in `resources'
2023-02-23 18:05:01 /usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.0/lib/logstash/inputs/cloudwatch.rb:179:in `from_resources'
2023-02-23 18:05:01 /usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.0/lib/logstash/inputs/cloudwatch.rb:163:in `block in run'
2023-02-23 18:05:01 org/jruby/RubyArray.java:1865:in `each'
2023-02-23 18:05:01 /usr/share/logstash/vendor/bundle/jruby/2.6.0/gems/logstash-integration-aws-7.0.0/lib/logstash/inputs/cloudwatch.rb:157:in `run'
2023-02-23 18:05:01 /usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:411:in `inputworker'
2023-02-23 18:05:01 /usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:402:in `block in start_input'
2023-02-23 18:05:02 [2023-02-23T09:05:02,680][INFO][logstash.inputs.cloudwatch][main][2ef442e73669393d64dca610d218d966d3ce2bda88f9b05d28491f8b52a8bf03] Polling CloudWatch API
2023-02-23 18:05:02 [2023-02-23T09:05:02,685][ERROR][logstash.javapipeline][main][2ef442e73669393d64dca610d218d966d3ce2bda88f9b05d28491f8b52a8bf03] A plugin had an unrecoverable error. Will restart this plugin.

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 23, 2023, 10:28am UTC](https://discuss.elastic.co/t/problems-with-cloudwatch-input-plugin-namespace-aws-ec2-nameerror/326297/2 "2023-03-23T10:28:03Z")

</div>

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