# Grok filter - space not working

**URL:** https://discuss.elastic.co/t/grok-filter-space-not-working/80141
**Category:** Logstash
**Created:** [March 27, 2017, 1:52pm UTC](https://discuss.elastic.co/t/grok-filter-space-not-working/80141 "2017-03-27T13:52:25Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![August\_rush](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@August\_rush](https://discuss.elastic.co/u/August_rush)
#### Post date: [March 27, 2017, 1:52pm UTC](https://discuss.elastic.co/t/grok-filter-space-not-working/80141/1 "2017-03-27T13:52:25Z")

</div>

Hi , I am trying to use grok filter on this log , There is a space after WARN I have tried using %s\* \s\* and also %{SPACE} but it is not triggering an email. can some one please help me.

[2017-03-25T00:00:07,137][WARN]

```
input {
  file {
    path => "/var/log/logstash/sample"
    start_position => beginning
  }
}

filter {
  grok {
    match => { "message" => "\[%{TIMESTAMP_ISO8601:timestamp}\]\[%{LOGLEVEL:log-level}\s*\]" }
  }
}
output {
  email {
        port => 25
        address => "mail.tck.com"
        authentication => "login"
        use_tls => true
        from => "alerts@logstash.com"
        subject => "logstash alert"
        to => "abc@tck.com"
        via => "smtp"
        body => "%{message}"
        debug => true
  }
}
~                                                                                                                                                                                                                  

```

~  
I am using log stash 2.2.4

---

<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 27, 2017, 2:33pm UTC](https://discuss.elastic.co/t/grok-filter-space-not-working/80141/2 "2017-03-27T14:33:39Z")

</div>

Your grok filter doesn't affect whether an email is sent or not. If you're not getting an email that could be because

- Logstash isn't reading any lines from the file,
- the email output isn't working,
- the email is getting held up somewhere outside of Logstash.

---

<div class="post-metadata">

### Author: ![August\_rush](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@August\_rush](https://discuss.elastic.co/u/August_rush)
#### Post date: [March 27, 2017, 2:37pm UTC](https://discuss.elastic.co/t/grok-filter-space-not-working/80141/3 "2017-03-27T14:37:57Z")

</div>

I tried to change the log file (without space after WARN) and it worked by sending an email.  
[2017-03-25T00:00:07,137][WARN]  
`match => { "message" => "\[%{TIMESTAMP_ISO8601:timestamp}\]\[%{LOGLEVEL:log-level}\]" }`

```
so thus, i think there is something wrong with my filter.
Does grok filter (\s*) work only for logstash versions 2.4 and above , i am using 2.2.4
```

---

<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 27, 2017, 2:41pm UTC](https://discuss.elastic.co/t/grok-filter-space-not-working/80141/4 "2017-03-27T14:41:07Z")

</div>

> Does grok filter (\s\*) work only for logstash versions 2.4 and above , i am using 2.2.4

No, that's standard regexp notation that works on any version of Logstash.

---

<div class="post-metadata">

### Author: ![August\_rush](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@August\_rush](https://discuss.elastic.co/u/August_rush)
#### Post date: [March 27, 2017, 5:28pm UTC](https://discuss.elastic.co/t/grok-filter-space-not-working/80141/5 "2017-03-27T17:28:06Z")

</div>

Thanks Magnus, yes it was some issue with the mail server.  
Now its working.

---

<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 24, 2017, 5:28pm UTC](https://discuss.elastic.co/t/grok-filter-space-not-working/80141/6 "2017-04-24T17:28:09Z")

</div>

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