# Mutate converts integer to string

**URL:** https://discuss.elastic.co/t/mutate-converts-integer-to-string/123092
**Category:** Logstash
**Created:** [March 8, 2018, 2:19pm UTC](https://discuss.elastic.co/t/mutate-converts-integer-to-string/123092 "2018-03-08T14:19:26Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)
#### Post date: [March 8, 2018, 2:19pm UTC](https://discuss.elastic.co/t/mutate-converts-integer-to-string/123092/1 "2018-03-08T14:19:26Z")

</div>

We have the following filter (Logstash 6.2 Windows):

```
if [category] == "hybrisserver" and [raw] =~ "Starting up hybris server" {
	mutate { update => {"priority" => 2 "category" => "ServerStart" } }
}

```

The incoming events have priority as an integer (see 2nd event in screenshot below) but after mutate it's a string:

![image](https://us1.discourse-cdn.com/elastic/original/3X/d/5/d5c56a714ffa39a922b95d8ea77c7b538e879ac0.jpg)

---

<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: [March 8, 2018, 2:37pm UTC](https://discuss.elastic.co/t/mutate-converts-integer-to-string/123092/2 "2018-03-08T14:37:25Z")

</div>

> [@cawoodm](#):
>
> The incoming events have priority as an integer [...] but after mutate it's a string

This is true. Update replaces the current value of a field with a string. You could convert the field if you need it to be an integer.

---

<div class="post-metadata">

### Author: ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)
#### Post date: [March 8, 2018, 3:09pm UTC](https://discuss.elastic.co/t/mutate-converts-integer-to-string/123092/3 "2018-03-08T15:09:06Z")

</div>

Are you stating the obvious 😉 or saying this is by design?

IMHO it's a bug.

---

<div class="post-metadata">

### Author: ![cawoodm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cawoodm/32/14083_2.png) [@cawoodm](https://discuss.elastic.co/u/cawoodm)
#### Post date: [March 8, 2018, 3:10pm UTC](https://discuss.elastic.co/t/mutate-converts-integer-to-string/123092/4 "2018-03-08T15:10:12Z")

</div>

Just to be clear: "priority" is not really in the input. It's created via the following filter:

```
translate {
	field => "type"
	destination => "priority"
	dictionary => {
		"ERROR" => 3
		"WARN" => 2
		"INFO" => 1
		"DEBUG" => 0
	}
}
```

---

<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: [March 10, 2018, 8:38pm UTC](https://discuss.elastic.co/t/mutate-converts-integer-to-string/123092/5 "2018-03-10T20:38:32Z")

</div>

> IMHO it's a bug.

I agree. Logstash's configuration language doesn't have integer literals, and quotes are optional for strings so `2` is treated as `"2"`.

---

<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: [April 7, 2018, 8:38pm UTC](https://discuss.elastic.co/t/mutate-converts-integer-to-string/123092/6 "2018-04-07T20:38:36Z")

</div>

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