# Multi dimension filter for logstash-input-cloudwatch plugin

**URL:** <https://discuss.elastic.co/t/multi-dimension-filter-for-logstash-input-cloudwatch-plugin/163647>\
**Category:** Logstash\
**Created:** [January 10, 2019, 2:45am UTC](https://discuss.elastic.co/t/multi-dimension-filter-for-logstash-input-cloudwatch-plugin/163647 "2019-01-10T02:45:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Izek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/izek/32/37113_2.png) [@Izek](https://discuss.elastic.co/u/Izek)\
**Post date:** [January 10, 2019, 2:45am UTC](https://discuss.elastic.co/t/multi-dimension-filter-for-logstash-input-cloudwatch-plugin/163647/1 "2019-01-10T02:45:53Z")

</div>

I get a error message hen I using the logstash-input-cloudwatch to retrieve the metric with Multi dimension.  
Not sure the filters format is correct or not.

config

```json
  cloudwatch {
    namespace => "sqlserver"
    metrics => [
        "FreeableMemory"
    ]
    filters => [{host => Remedy}, {objectname => Memory}]
    region => "ap-northeast-1"
    interval => 600
    period => 300
  }

```

Error message

```json
[2019-01-10T10:44:27,228][ERROR][logstash.pipeline] A plugin had an unrecoverable error. Will restart this plugin.
  Pipeline_id:main
  Plugin: <LogStash::Inputs::CloudWatch period=>300, namespace=>"sqlserver", nterval=>600, metrics=>["FreeableMemory"], filters=>[{"host"=>"Remedy"}, {"objectname"=>"Memory"}], id=>"59329e8a6b9e99e6ac1185964ba6189ff5991ad940c0730d7dbce9bf5619b3ce", region=>"ap-northeast-1", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_e1b0bc86-8438-4b26-9770-32635ea6bfd1", enable_metric=>true, charset=>"UTF-8">, role_session_name=>"logstash", statistics=>["SampleCount", "Average", "Minimum", "Maximum", "Sum"], combined=>false>
  Error: undefined method `each_pair' for [{"host"=>"Remedy"}, {"objectname"=>"Memory"}]:Array
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:409:in `inputworker'
/usr/share/logstash/logstash-core/lib/logstash/pipeline.rb:403:in `block in start_input'

```

---

<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:** [January 10, 2019, 2:59pm UTC](https://discuss.elastic.co/t/multi-dimension-filter-for-logstash-input-cloudwatch-plugin/163647/2 "2019-01-10T14:59:07Z")

</div>

If you look at the [code](https://github.com/logstash-plugins/logstash-input-cloudwatch/blob/46bc164dd5222014f0cf5f04365ae2a5cb45ff27/lib/logstash/inputs/cloudwatch.rb#L179), it is calling each\_pair against resources. each\_pair is a function of a hash. For your namespace, resources is @filters.

Filters is [documented](https://www.elastic.co/guide/en/logstash/current/plugins-inputs-cloudwatch.html#plugins-inputs-cloudwatch-filters) as taking an array, but all the examples show a hash. Array and hash are sometimes, but not always, interchangeable.

What do you get if you set

```
filters => {host => Remedy objectname => Memory}
```

---

<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:** [February 7, 2019, 2:59pm UTC](https://discuss.elastic.co/t/multi-dimension-filter-for-logstash-input-cloudwatch-plugin/163647/3 "2019-02-07T14:59:11Z")

</div>

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