# Ruby Filter Exception: No implicit conversion of Fixnum into String

**URL:** <https://discuss.elastic.co/t/ruby-filter-exception-no-implicit-conversion-of-fixnum-into-string/156192>\
**Category:** Logstash\
**Created:** [November 11, 2018, 10:34am UTC](https://discuss.elastic.co/t/ruby-filter-exception-no-implicit-conversion-of-fixnum-into-string/156192 "2018-11-11T10:34:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dx123](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dx123](https://discuss.elastic.co/u/dx123)\
**Post date:** [November 11, 2018, 10:34am UTC](https://discuss.elastic.co/t/ruby-filter-exception-no-implicit-conversion-of-fixnum-into-string/156192/1 "2018-11-11T10:34:24Z")

</div>

Here is my aggregation query:

```
{
  "size": 0,
  "aggs": {
    "range": {
      "date_range": {
        "field": "source time",
        "ranges": [
          {
            "from": "2018-01-01",
            "to": "now/d"
          }
        ]
      },
      "aggs": {
        "by ip": {
          "terms": {
            "field": "ip.keyword",
            "size": 300
          },
          "aggs": {
            "by date": {
              "date_histogram": {
                "field": "source time",
                "interval": "day"
              }
            }
          }
        }
      }
    }
  }
}

```

and sample response:

```auto
 "aggregations": {
    "range": {
      "buckets": [
        {
          "key": "2018-01-01T00:00:00.000Z-2018-11-11T00:00:00.000Z",
          "from_as_string": "2018-01-01T00:00:00.000Z",
          "to_as_string": "2018-11-11T00:00:00.000Z",
          "doc_count": 13000,
          "by ip": {
            "buckets": [
              {
                "key": "192.168.0.1",
                "doc_count": 20
                "by date": {
                  "buckets": [
                    {
                      "key_as_string": "2018-04-30T00:00:00.000Z",
                      "doc_count": 10,
                      .
                      .
                      .

```

I have a separate Logstash configuration file that takes in this aggregated response as input and performs some data manipulations such as renaming of aggregated fields before parsing it back into Elasticsearch as a new index.

Here's part of my filter plugin where I use Ruby filter to rename the "key\_as\_string" date field.

```
filter {
	split { 
		field => "[aggregations][range][buckets]" 
	}

	split { 
		field => "[aggregations][range][buckets][by ip][buckets]" 
	}

	split { 
		field => "[aggregations][range][buckets][by ip][buckets][by date][buckets]" 
	}

	ruby {
		code => "event.set('Source Time', event.get('[aggregations][range][buckets][by ip][buckets][by date][buckets][key_as_string]'))"
	}
}

```

However I am getting this Ruby exception error "No implicit conversion of Fixnum into String". Please advise.

---

<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:** [December 9, 2018, 10:34am UTC](https://discuss.elastic.co/t/ruby-filter-exception-no-implicit-conversion-of-fixnum-into-string/156192/2 "2018-12-09T10:34:26Z")

</div>

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