# Trying to parse when LOGLEVEL is ERROR

**URL:** https://discuss.elastic.co/t/trying-to-parse-when-loglevel-is-error/220378
**Category:** Logstash
**Created:** [February 21, 2020, 1:40pm UTC](https://discuss.elastic.co/t/trying-to-parse-when-loglevel-is-error/220378 "2020-02-21T13:40:27Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![dbviz](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@dbviz](https://discuss.elastic.co/u/dbviz)
#### Post date: [February 21, 2020, 1:40pm UTC](https://discuss.elastic.co/t/trying-to-parse-when-loglevel-is-error/220378/1 "2020-02-21T13:40:28Z")

</div>

Hello,

Im trying to parse only LOGLEVEL field using grok but it doesn't work.

My logstash.log comes from :

`[2020-02-20T15:55:46,198][ERROR][logstash.inputs.jdbc] Java::ComSybaseJdbc3Jdbc::SybSQLException: Difference of two datetime fields caused overflow at runtime.:`  
`[2020-02-20T16:27:36,610][INFO][logstash.pipeline] Pipeline has terminated {:pipeline_id=>"main", :thread=>"#<Thread:0x1b10a501 run>"}`

and the grock filter

```
input {
   file {
		path => "/logs/logstash-plain-duplicate.log"        
   }
}

#############
#############
filter {
 grok {
        match => { "message" => "%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL:level} \s+[%{JAVACLASS:class}] %{GREEDYDATA:message} " }
    }
	 mutate{
		 add_field =>{
		 "lvl" => "%{LOGLEVEL}"
		 }
	 }
}
#############
#############

output {
		stdout { codec => rubydebug }
}

```

And here is the result :

```
{
      "@version" => "1",
          "path" => "/logs/logstash-plain-duplicate.log",
          "host" => "SERV100",
    "@timestamp" => 2020-02-21T13:38:31.138Z,
          "tags" => [
        [0] "_grokparsefailure"
    ],
           "lvl" => "%{LOGLEVEL}",
       "message" => "[2020-02-20T15:55:46,198][ERROR][logstash.inputs.jdbc] Java::ComSybaseJdbc3Jdbc::SybSQLException: Difference of two datetime fields caused overflow at runtime.:"
}

```

Thank you 🙂

---

<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: [February 21, 2020, 3:33pm UTC](https://discuss.elastic.co/t/trying-to-parse-when-loglevel-is-error/220378/2 "2020-02-21T15:33:44Z")

</div>

You grok pattern does not match the message. You need to include all the square brackets etc. in the pattern, and they will need to be escaped.

---

<div class="post-metadata">

### Author: ![dbviz](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@dbviz](https://discuss.elastic.co/u/dbviz)
#### Post date: [February 21, 2020, 3:51pm UTC](https://discuss.elastic.co/t/trying-to-parse-when-loglevel-is-error/220378/3 "2020-02-21T15:51:18Z")

</div>

> [@dbviz](#):
>
> grok

Thank you Badger for your reply.

I used [https://grokdebug.herokuapp.com/](https://grokdebug.herokuapp.com/) to compare with grok pattern but its not working

---

<div class="post-metadata">

### Author: ![dbviz](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@dbviz](https://discuss.elastic.co/u/dbviz)
#### Post date: [February 26, 2020, 10:00am UTC](https://discuss.elastic.co/t/trying-to-parse-when-loglevel-is-error/220378/4 "2020-02-26T10:00:21Z")

</div>

Anyone have the GROK example for this ?

> [@dbviz](#):
>
> `[2020-02-20T15:55:46,198][ERROR][logstash.inputs.jdbc] Java::ComSybaseJdbc3Jdbc::SybSQLException: Difference of two datetime fields caused overflow at runtime.:`  
> `[2020-02-20T16:27:36,610][INFO][logstash.pipeline] Pipeline has terminated {:pipeline_id=>"main", :thread=>"#<Thread:0x1b10a501 run>"}`

---

<div class="post-metadata">

### Author: ![dbviz](https://avatars.discourse-cdn.com/v4/letter/d/e19b73/32.png) [@dbviz](https://discuss.elastic.co/u/dbviz)
#### Post date: [February 27, 2020, 10:44am UTC](https://discuss.elastic.co/t/trying-to-parse-when-loglevel-is-error/220378/5 "2020-02-27T10:44:36Z")

</div>

The solution :

> [%{TIMESTAMP\_ISO8601:timestamp}][%{DATA:loglevel}%{SPACE}][%{JAVACLASS:class}%{SPACE}] %{GREEDYDATA: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: [March 26, 2020, 10:44am UTC](https://discuss.elastic.co/t/trying-to-parse-when-loglevel-is-error/220378/6 "2020-03-26T10:44:41Z")

</div>

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