# Parsing log line sends information twice

**URL:** <https://discuss.elastic.co/t/parsing-log-line-sends-information-twice/219652>\
**Category:** Logstash\
**Created:** [February 17, 2020, 4:14pm UTC](https://discuss.elastic.co/t/parsing-log-line-sends-information-twice/219652 "2020-02-17T16:14:41Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdamJade](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@AdamJade](https://discuss.elastic.co/u/AdamJade)\
**Post date:** [February 17, 2020, 4:14pm UTC](https://discuss.elastic.co/t/parsing-log-line-sends-information-twice/219652/1 "2020-02-17T16:14:41Z")

</div>

Hi there  
Here is my log line

[2020/02/11-20:22:06.643] !! Nom de classe de la BS : WXWXWX.Mtr.GpePayerEncaisser.Execution.Batchs.BS\_RequestExecution

I want to obtain a message like this  
datetime : 2020/02/11-20:22:06.643  
message : Nom de classe de la BS : WXWXWX.Mtr.GpePayerEncaisser.Execution.Batchs.BS\_RequestExecution to push it in elasticsearch.  
Here is my filter

filter {  
grok {  
match =\> { "message" =\> "(?\<REQ\_TIME\>%{YEAR}/%{MONTHNUM}/%{MONTHDAY} %{TIME})?%{GREEDYDATA:message}" }  
}   
}  
All i got is the line  
"message":["[2020/02/11-20:22:06.659] !! Date & heure : mar. 11 févr. 2020 20:22:06" twice.  
Thanks for any help

---

<div class="post-metadata">

**Author:** ![ahmed\_charafouddine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ahmed_charafouddine/32/45129_2.png) [@ahmed\_charafouddine](https://discuss.elastic.co/u/ahmed_charafouddine)\
**Post date:** [February 17, 2020, 4:28pm UTC](https://discuss.elastic.co/t/parsing-log-line-sends-information-twice/219652/2 "2020-02-17T16:28:08Z")

</div>

You can try this :

```
 filter {
        grok {
            match => {
                "message" => "\[%{GREEDYDATA:tmp}\]%{SPACE}!!%{GREEDYDATA:reste}"
            }
        }

        date {
            locale => "fr"
            match => ["tmp", "YYYY/MM/dd-HH:mm:ss.SSSSSS"]
            timezone => "Europe/Paris"
            target => "@timestamp"
            remove_field => "tmp" # Suppression du champs tmp.
        }
    }
```

---

<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 17, 2020, 4:28pm UTC](https://discuss.elastic.co/t/parsing-log-line-sends-information-twice/219652/3 "2020-02-17T16:28:59Z")

</div>

Your REQ\_TIME pattern does not match the message. It does not match the square brackets and it separates date and time using space rather than a hyphen. You have made it optional (the trailing ?) so the entire value of [message] is consumed by %{GREEDYDATA:message}, which just adds a second copy of [message] to [message].

Do not make REQ\_TIME optional but also anchor it to start of line using ^

---

<div class="post-metadata">

**Author:** ![AdamJade](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@AdamJade](https://discuss.elastic.co/u/AdamJade)\
**Post date:** [February 18, 2020, 3:10pm UTC](https://discuss.elastic.co/t/parsing-log-line-sends-information-twice/219652/4 "2020-02-18T15:10:28Z")

</div>

Hi Ahmed, thank's so much, it works.

---

<div class="post-metadata">

**Author:** ![AdamJade](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@AdamJade](https://discuss.elastic.co/u/AdamJade)\
**Post date:** [February 18, 2020, 3:10pm UTC](https://discuss.elastic.co/t/parsing-log-line-sends-information-twice/219652/5 "2020-02-18T15:10:53Z")

</div>

Right, thank's a lot Badger.

---

<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 17, 2020, 3:16pm UTC](https://discuss.elastic.co/t/parsing-log-line-sends-information-twice/219652/6 "2020-03-17T15:16:24Z")

</div>

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