# Grok pattern match but replace a character from result

**URL:** <https://discuss.elastic.co/t/grok-pattern-match-but-replace-a-character-from-result/209084>\
**Category:** Logstash\
**Created:** [November 22, 2019, 3:54pm UTC](https://discuss.elastic.co/t/grok-pattern-match-but-replace-a-character-from-result/209084 "2019-11-22T15:54:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GaryD007](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@GaryD007](https://discuss.elastic.co/u/GaryD007)\
**Post date:** [November 22, 2019, 3:54pm UTC](https://discuss.elastic.co/t/grok-pattern-match-but-replace-a-character-from-result/209084/1 "2019-11-22T15:54:15Z")

</div>

Hi all  
I am trying to extract the timestamp from a log file but the date and time are separated by a semicolon. Is there a way I can make my Grok pattern work but replace the semicolon with a space ?

Here is a sample from the log -  
2019-11-18;05:10:55.954;INFORMATION;domain;test.user;2;1120;CheckUserExistsInGroup: No Entries Found In ExcludedGroups

this is my Grok pattern -  
%{TS\_CUST:timestamp:ts-"2006-01-02 15:04:05.999"};%{WORD:Status:tag};%{WORD:Domain:tag};%{USERNAME:username:tag};%{NUMBER:SessionID:int};%{NUMBER:ProcessID:int};%{WORD:Action}: %{GREEDYDATA:message}  
TS\_CUST %{YEAR}-%{MONTHNUM}-%{MONTHDAY};%{TIME}

and from grok debugger here is the output -

{  
"timestamp": [  
"2019-11-18;05:10:55.954"  
],  
"Status": [  
"INFORMATION"  
],  
"Domain": [  
"domain"  
],  
"username": [  
"test.user"  
],  
"Action": [  
"CheckUserExistsInGroup"  
],  
"message": [  
"No Entries Found In ExcludedGroups"  
]  
}

I have been trying for ages to get rid of the semicolon between the date and time and replace with a 'space' in the 'timestamp' match as influxDB won't accept the timestamp with the semicolon. It seems that the semicolon is not being 'escaped' in my pattern. Any help would be greatly appreciated

---

<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:** [November 22, 2019, 4:11pm UTC](https://discuss.elastic.co/t/grok-pattern-match-but-replace-a-character-from-result/209084/2 "2019-11-22T16:11:11Z")

</div>

You could use [mutate+gsub](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-gsub) to replace the semicolon with a space.

---

<div class="post-metadata">

**Author:** ![GaryD007](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@GaryD007](https://discuss.elastic.co/u/GaryD007)\
**Post date:** [November 22, 2019, 4:22pm UTC](https://discuss.elastic.co/t/grok-pattern-match-but-replace-a-character-from-result/209084/3 "2019-11-22T16:22:27Z")

</div>

Thanks Badger - I may have posted in the wrong place but I am using a Telegraf logparser plugin using Grok inputs and I don't think I can use mutate-gsub

---

<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:** [December 20, 2019, 4:22pm UTC](https://discuss.elastic.co/t/grok-pattern-match-but-replace-a-character-from-result/209084/4 "2019-12-20T16:22:32Z")

</div>

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