# Grok processor: Expected output to be decimal, but output was string

**URL:** <https://discuss.elastic.co/t/grok-processor-expected-output-to-be-decimal-but-output-was-string/180123>\
**Category:** Elasticsearch\
**Created:** [May 8, 2019, 8:16am UTC](https://discuss.elastic.co/t/grok-processor-expected-output-to-be-decimal-but-output-was-string/180123 "2019-05-08T08:16:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Miao](https://avatars.discourse-cdn.com/v4/letter/m/8baadc/32.png) [@Miao](https://discuss.elastic.co/u/Miao)\
**Post date:** [May 8, 2019, 8:16am UTC](https://discuss.elastic.co/t/grok-processor-expected-output-to-be-decimal-but-output-was-string/180123/1 "2019-05-08T08:16:18Z")

</div>

I created a pipeline called `parse_duration`:

```auto
{
  "description" : "ParseDuration",
  "processors": [
    {
      "grok": {
        "field": "Duration",
        "patterns": ["%{NUMBER:DrillDuration}"]
      }
    }
  ]
}

```

I simulated posting some dummy data while invoking the pipeline:

```auto
{
  "docs": [
    {
      "_source": {
        "Duration": "4.13"
      }
    }
  ]
}

```

This was the response message:

```auto
{
    "docs": [
        {
            "doc": {
                "_index": "_index",
                "_type": "_doc",
                "_id": "_id",
                "_source": {
                    "DrillDuration": "4.13",
                    "Duration": "4.13"
                },
                "_ingest": {
                    "timestamp": "2019-05-08T08:13:35.339Z"
                }
            }
        }
    ]
}

```

When I posted some actual data and loaded them into Kibana, `DrillDuration` is considered to be a string value:

![image](https://us1.discourse-cdn.com/elastic/original/3X/0/5/05a7c73f285a2bd50ab11e42ec61ced7a2d5f19f.png)

I want `DrillDuration` to be a decimal or a double. How should I fix my pipeline definition to achieve this?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [May 8, 2019, 8:22am UTC](https://discuss.elastic.co/t/grok-processor-expected-output-to-be-decimal-but-output-was-string/180123/2 "2019-05-08T08:22:48Z")

</div>

See the [grok basics paragraph](https://www.elastic.co/guide/en/elasticsearch/reference/7.0/grok-processor.html#grok-basics) in the docs. You need to specify the type in addition

> The syntax for reusing a grok pattern comes in three forms: `%{SYNTAX:SEMANTIC}` , `%{SYNTAX}` , `%{SYNTAX:SEMANTIC:TYPE}` .

> The `TYPE` is the type you wish to cast your named field. `int` , `long` , `double` , `float` and `boolean` are supported types for coercion.

You would need to use `"%{NUMBER:DrillDuration:float}"`

hope this helps

---

<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:** [June 5, 2019, 8:22am UTC](https://discuss.elastic.co/t/grok-processor-expected-output-to-be-decimal-but-output-was-string/180123/3 "2019-06-05T08:22:49Z")

</div>

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