# Replace in Logstash

**URL:** https://discuss.elastic.co/t/replace-in-logstash/174331
**Category:** Logstash
**Created:** [March 28, 2019, 12:27pm UTC](https://discuss.elastic.co/t/replace-in-logstash/174331 "2019-03-28T12:27:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Gabriela\_Zielinska](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gabriela_zielinska/32/42978_2.png) [@Gabriela\_Zielinska](https://discuss.elastic.co/u/Gabriela_Zielinska)
#### Post date: [March 28, 2019, 12:27pm UTC](https://discuss.elastic.co/t/replace-in-logstash/174331/1 "2019-03-28T12:27:40Z")

</div>

Hi  
I'm trying to replace some strings in field message in with Logstash

My logstash configuration:  
input {  
beats {  
port =\> 5044  
}  
}  
filter {  
mutate {  
gsub =\> ["message", "s", "X"]  
}  
}

```
output {
  elasticsearch {
    host => "localhost"
    port => "9200"
    protocol => "http"
    index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
    document_type => "%{[@metadata][type]}"
  }
}

```

in this example i tried to replace s with X, but it didn't work. Could you tell my why and how i should do it?

my filebeat input:  
- type: log  
enabled: true  
paths:  
- /var/log/out/\*.log  
multiline.pattern: '^['  
multiline.negate: true  
multiline.match: after

```
- type: log
  enabled: true
  paths:
    - /var/log/err/*.log
  multiline.pattern: 'R [a-zA-Z]'
  multiline.negate: true
  multiline.match: after

```

filebeat output:  
output.logstash:  
# The Logstash hosts  
hosts: ["localhost:5044"]

---

<div class="post-metadata">

### Author: ![kharvey](https://avatars.discourse-cdn.com/v4/letter/k/d07c76/32.png) [@kharvey](https://discuss.elastic.co/u/kharvey)
#### Post date: [April 1, 2019, 5:13pm UTC](https://discuss.elastic.co/t/replace-in-logstash/174331/2 "2019-04-01T17:13:08Z")

</div>

That looks correct to me.

Do you have an example log that you are trying this on?

This is the gsub that I use on one of my log sets:

```auto
filter {
  mutate {
    gsub => ['message', '\r', '']
    strip => ['message']
  }
}
```

---

<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 29, 2019, 5:13pm UTC](https://discuss.elastic.co/t/replace-in-logstash/174331/3 "2019-04-29T17:13:09Z")

</div>

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