# How to assign a new field a certain type and value?

**URL:** <https://discuss.elastic.co/t/how-to-assign-a-new-field-a-certain-type-and-value/34148>\
**Category:** Logstash\
**Created:** [November 9, 2015, 12:45pm UTC](https://discuss.elastic.co/t/how-to-assign-a-new-field-a-certain-type-and-value/34148 "2015-11-09T12:45:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [November 9, 2015, 7:45pm UTC](https://discuss.elastic.co/t/how-to-assign-a-new-field-a-certain-type-and-value/34148/2 "2015-11-09T19:45:35Z")

</div>

Perhaps surprisingly, `mutate { add_field => { somefield => 1 } }` doesn't actually add an integer field:

```
$ cat test.config
input { stdin { } }
output { stdout { codec => rubydebug } }
filter {
  mutate {
    add_field => { "somefield" => 1 }
  }
}
$ echo 'foo' | /opt/logstash/bin/logstash -f test.config
Logstash startup completed
{
       "message" => "foo",
      "@version" => "1",
    "@timestamp" => "2015-11-09T19:45:06.364Z",
          "host" => "hallonet",
     "somefield" => "1"
}
Logstash shutdown completed

```

Use a second mutate filter to convert the field.

---

_[View the full topic](https://discuss.elastic.co/t/how-to-assign-a-new-field-a-certain-type-and-value/34148)._
