# Array not getting accepted for "filters" parameter? Plugin:logstash-input-cloudwatch

**URL:** <https://discuss.elastic.co/t/array-not-getting-accepted-for-filters-parameter-plugin-logstash-input-cloudwatch/185194>\
**Category:** Logstash\
**Created:** [June 11, 2019, 1:11pm UTC](https://discuss.elastic.co/t/array-not-getting-accepted-for-filters-parameter-plugin-logstash-input-cloudwatch/185194 "2019-06-11T13:11:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![skerkar](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@skerkar](https://discuss.elastic.co/u/skerkar)\
**Post date:** [June 11, 2019, 1:11pm UTC](https://discuss.elastic.co/t/array-not-getting-accepted-for-filters-parameter-plugin-logstash-input-cloudwatch/185194/1 "2019-06-11T13:11:32Z")

</div>

Hi,

I am trying to fetch metrics for ES using "logstash-input-cloudwatch" plugin. As per docs, "filters" configuration is of 'array' type.  
For fetching ES metrics, I need to pass DomainName and ClientId both, but plugin is throwing an error for datatype.  
Examples on documentation page shows value as hash rather than array.  
[https://www.elastic.co/guide/en/logstash/6.6/plugins-inputs-cloudwatch.html#plugins-inputs-cloudwatch-filters](http://plugins-inputs-cloudwatch).

I have tried below values for filters, but none worked:

`filters => { "DomainName" => "DOMAIN_NAME", "ClientId" => "ACCOUNT_ID" }`

`filters => [{ "DomainName" => "DOMAIN_NAME"}, {"ClientId" => "ACCOUNT_ID" }]`

Can anybody please suggest on this?

Thanks

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 11, 2019, 2:48pm UTC](https://discuss.elastic.co/t/array-not-getting-accepted-for-filters-parameter-plugin-logstash-input-cloudwatch/185194/2 "2019-06-11T14:48:11Z")

</div>

Given the way it is [used](https://github.com/logstash-plugins/logstash-input-cloudwatch/blob/79cf393630cefb69b5d8a89b78b94e41771ad140/lib/logstash/inputs/cloudwatch.rb#L298), the only format that makes sense to me is an array of arrays

```
filters => [[ "DomainName", "DOMAIN_NAME"], ["ClientId", "ACCOUNT_ID"] ]
```

---

<div class="post-metadata">

**Author:** ![skerkar](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@skerkar](https://discuss.elastic.co/u/skerkar)\
**Post date:** [June 11, 2019, 4:10pm UTC](https://discuss.elastic.co/t/array-not-getting-accepted-for-filters-parameter-plugin-logstash-input-cloudwatch/185194/3 "2019-06-11T16:10:55Z")

</div>

Thanks a lot @Badger.

Configuration file is accepted now with multiple filters, but script is failing at next stage with below error:

> Error: undefined method `each_pair' for #<Array:0x6f71fa5c> Did you mean? each_entry Exception: NoMethodError Stack: /usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-input-cloudwatch-2.2.4/lib/logstash/inputs/cloudwatch.rb:179:in `from\_resources'  
> /usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-input-cloudwatch-2.2.4/lib/logstash/inputs/cloudwatch.rb:163:in `block in run' org/jruby/RubyArray.java:1734:in `each'  
> /usr/share/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-input-cloudwatch-2.2.4/lib/logstash/inputs/cloudwatch.rb:157:in `run' /usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:426:in `inputworker'  
> /usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:420:in `block in start\_input'

Is it something related to multiple filters?

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [June 11, 2019, 4:21pm UTC](https://discuss.elastic.co/t/array-not-getting-accepted-for-filters-parameter-plugin-logstash-input-cloudwatch/185194/4 "2019-06-11T16:21:11Z")

</div>

Yeah. The code is inconsistent. It declares filters as an array, and if you want multiple filters [this](https://github.com/logstash-plugins/logstash-input-cloudwatch/blob/79cf393630cefb69b5d8a89b78b94e41771ad140/lib/logstash/inputs/cloudwatch.rb#L298) means it has to be an array. However, all of the documentation shows it as a hash and [this](https://github.com/logstash-plugins/logstash-input-cloudwatch/blob/79cf393630cefb69b5d8a89b78b94e41771ad140/lib/logstash/inputs/cloudwatch.rb#L330) line of code means it has to be a hash. I would say that is a bug and you should mention this on that github issue you replied to a few hours back.

---

<div class="post-metadata">

**Author:** ![skerkar](https://avatars.discourse-cdn.com/v4/letter/s/e5b9ba/32.png) [@skerkar](https://discuss.elastic.co/u/skerkar)\
**Post date:** [June 11, 2019, 4:24pm UTC](https://discuss.elastic.co/t/array-not-getting-accepted-for-filters-parameter-plugin-logstash-input-cloudwatch/185194/5 "2019-06-11T16:24:38Z")

</div>

Thanks @Badger.

I tried debugging the plugin source code but I don't have knowledge about ruby so couldn't find much.  
Thanks for your pointers.

---

<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:** [July 9, 2019, 4:37pm UTC](https://discuss.elastic.co/t/array-not-getting-accepted-for-filters-parameter-plugin-logstash-input-cloudwatch/185194/6 "2019-07-09T16:37:25Z")

</div>

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