# Pattern: grok/mutate dont work?

**URL:** https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212
**Category:** Logstash
**Created:** [October 21, 2022, 3:15pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212 "2022-10-21T15:15:56Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![kurdit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kurdit/32/54994_2.png) [@kurdit](https://discuss.elastic.co/u/kurdit)
#### Post date: [October 21, 2022, 3:15pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/1 "2022-10-21T15:15:56Z")

</div>

hi all! i ran into a problem.  
i have a pipeline:

```auto
input {
    tcp {
        host => "10.10.10.10"
        port => "5959"
        codec => "json"
        type => "my_type"
        mode => "server"
    }
}

filter {
 if [type] == "my_type" {
    grok {
        match => {"message" => ['\#%{GREEDYDATA:who}%{SPACE}#%{GREEDYDATA:what}\n\n%{GREEDYDATA}: %{GREEDYDATA:contact}%{SPACE} #%{GREEDYDATA:ident}\n%{GREEDYDATA}Cost:%{SPACE}%{DATA:cost}\n%{GREEDYDATA}Date:%{SPACE}%{DATE_EU:when}\n%{GREEDYDATA}Vacant:%{SPACE}%{DATA:vacant}\n(?<info>(.|\r|\n)*)\n\[%{GREEDYDATA}']
           }
       }

    mutate {
        gsub => [
            "what", "milkshake", "Milk 🥛",
            "what", "icecream", "Ice 🍦"
            ]  
        }
        
    mutate {
        gsub => [
            "cost", "-1", "?",
            "contact", "9", "+9"
            ]  
        }
    
    mutate {
        gsub => [
            "contact", "\+9", "tel:+9"
            ]  
        }
        
      if [date] {
            date {
                match => ["date", "ISO8601", "YYYY-MM-dd'T'HH:mm:ss.ZZZ"]
                target => "@timestamp"
                } }

    if "_grokparsefailure" in [tags] {
    drop {}
            }
    }
}

output {
    if [type] == "my_type" {
        elasticsearch {
            hosts => ["https://localhost:9200"]
            index => "my_type-%{+xxxx.ww}"
            ilm_rollover_alias => "my_type"
            ilm_policy => "my_type"
            ilm_enabled => "true"
            cacert => ["/etc/logstash/ca.crt"]
            user => "elastic"
            password => "password"
        }
    }
}

```

in the mutate section after the GROK i replace one word with another which will contain emoji and be capitalized

```auto
mutate {
        gsub => [
            "what", "milkshake", "Milk 🥛",
            "what", "icecream", "Ice 🍦"
            ]  
        }

```

but in elasticsearch in the "what" field I see that the word is substituted with a non-capital letter "milk 🥛" instead of "Milk 🥛"

I tried to force mutate for the capital letter, but that doesn't help either ("mutate" for the capital letter was placed after the "mutate" for replacement)

```auto
mutate {
        capitalize => ["what"]
    }

```

What can be wrong?

---

<div class="post-metadata">

### Author: ![A\_Mightiev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_mightiev/32/62186_2.png) [@A\_Mightiev](https://discuss.elastic.co/u/A_Mightiev)
#### Post date: [October 23, 2022, 3:49pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/2 "2022-10-23T15:49:07Z")

</div>

Do you have something special in your index pattern mapping?

---

<div class="post-metadata">

### Author: ![kurdit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kurdit/32/54994_2.png) [@kurdit](https://discuss.elastic.co/u/kurdit)
#### Post date: [October 23, 2022, 8:19pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/3 "2022-10-23T20:19:40Z")

</div>

no, as far as i know, nothing special

---

<div class="post-metadata">

### Author: ![A\_Mightiev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_mightiev/32/62186_2.png) [@A\_Mightiev](https://discuss.elastic.co/u/A_Mightiev)
#### Post date: [October 23, 2022, 8:47pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/4 "2022-10-23T20:47:34Z")

</div>

Maybe instead of gsub you could use the translate plugin?

---

<div class="post-metadata">

### Author: ![kurdit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kurdit/32/54994_2.png) [@kurdit](https://discuss.elastic.co/u/kurdit)
#### Post date: [October 23, 2022, 8:50pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/5 "2022-10-23T20:50:27Z")

</div>

sorry what plugin are you talking about?

---

<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: [October 23, 2022, 8:58pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/6 "2022-10-23T20:58:15Z")

</div>

> [@kurdit](#):
>
> What can be wrong?

First verify that the problem is not in logstash by looking at what is produced by

```
output { stdout { codec => rubydebug } }

```

(or a file output with that codec). If the problem is on the elasticsearch side it could be an [analyzer filter](https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-lowercase-tokenfilter.html) or a [processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/lowercase-processor.html) in an ingestion pipeline.

---

<div class="post-metadata">

### Author: ![A\_Mightiev](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/a_mightiev/32/62186_2.png) [@A\_Mightiev](https://discuss.elastic.co/u/A_Mightiev)
#### Post date: [October 23, 2022, 9:50pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/7 "2022-10-23T21:50:14Z")

</div>

This plugin

> **[Translate filter plugin | Logstash Reference \[8.4\] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-filters-translate.html)**

---

<div class="post-metadata">

### Author: ![kurdit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kurdit/32/54994_2.png) [@kurdit](https://discuss.elastic.co/u/kurdit)
#### Post date: [October 23, 2022, 10:29pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/8 "2022-10-23T22:29:15Z")

</div>

with Translate filter pluginedit the same - the word is inserted in lowercase ☹

---

<div class="post-metadata">

### Author: ![kurdit](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kurdit/32/54994_2.png) [@kurdit](https://discuss.elastic.co/u/kurdit)
#### Post date: [October 23, 2022, 10:30pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/9 "2022-10-23T22:30:14Z")

</div>

no, i dont have analyzer or a processor in an ingestion pipeline

---

<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: [October 23, 2022, 10:59pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/10 "2022-10-23T22:59:40Z")

</div>

Does the rubydebug codec show it as uppercase or lowercase?

---

<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: [November 20, 2022, 10:59pm UTC](https://discuss.elastic.co/t/pattern-grok-mutate-dont-work/317212/11 "2022-11-20T22:59:53Z")

</div>

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