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
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
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.