# Logstash 2.4 grok mutate real with comma delimiter

**URL:** <https://discuss.elastic.co/t/logstash-2-4-grok-mutate-real-with-comma-delimiter/67847>\
**Category:** Logstash\
**Created:** [December 2, 2016, 11:07am UTC](https://discuss.elastic.co/t/logstash-2-4-grok-mutate-real-with-comma-delimiter/67847 "2016-12-02T11:07:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![caecilie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/caecilie/32/12472_2.png) [@caecilie](https://discuss.elastic.co/u/caecilie)\
**Post date:** [December 2, 2016, 11:07am UTC](https://discuss.elastic.co/t/logstash-2-4-grok-mutate-real-with-comma-delimiter/67847/1 "2016-12-02T11:07:29Z")

</div>

I need to parse the following line:  
`2016-12-02 11:54:03,107 Tests run: 2344, Failures: 0, Errors: 1, Skipped: 14, Time elapsed: 1,480.535 sec <<< FAILURE! - in com.werum.pasx.servicetests.ebrequipment.TestSuiteEbrEquipmentBf`

Here my grok pattern:

```
grok {
	  break_on_match => true
	  match => ["message", "(?m)%{TIMESTAMP_ISO8601}\s*%{TIMESTAMP_ISO8601:logdate}\s.*INFO\s.*?Time elapsed:\s(?<duration>[0-9.,+-]+)\s*sec\s.*com\.werum\.pasx\.%{DATA:probe}(\s|\n)%{GREEDYDATA:msg}"]
	  match => ["message", "(?m)%{TIMESTAMP_ISO8601}\s*%{TIMESTAMP_ISO8601:logdate}\s.*INFO\s.*?Time elapsed:\s(?<duration>[0-9.,+-]+)\s*sec\s.*com\.werum\.pasx\.%{GREEDYDATA:probe}"]
	  match => ["message", "(?m)%{TIMESTAMP_ISO8601}\s*%{TIMESTAMP_ISO8601:logdate}\s%{GREEDYDATA:msg}"]
	  match => ["message", "(?m)%{TIMESTAMP_ISO8601:logdate}\s%{GREEDYDATA:msg}"]
	}

	mutate {
	  convert => ["duration", "float"]
	}

```

It works, if the numbers follwing "Time collapsed:" don't contain a comma as delimiter. In my example duration contains 1 after mutating.  
Any idea, how I can get the correct number ?

---

<div class="post-metadata">

**Author:** ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)\
**Post date:** [December 3, 2016, 8:05am UTC](https://discuss.elastic.co/t/logstash-2-4-grok-mutate-real-with-comma-delimiter/67847/2 "2016-12-03T08:05:14Z")

</div>

Use gsub in mutate filter before mutate convert to get rid of the comma? [https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html)

---

<div class="post-metadata">

**Author:** ![caecilie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/caecilie/32/12472_2.png) [@caecilie](https://discuss.elastic.co/u/caecilie)\
**Post date:** [December 5, 2016, 8:22am UTC](https://discuss.elastic.co/t/logstash-2-4-grok-mutate-real-with-comma-delimiter/67847/3 "2016-12-05T08:22:22Z")

</div>

Thank, works, but only if I place gsub and convert in different mutates

```
mutate {
gsub => [
  # remove all comma 
  "duration", ",", ""
]
add_field => {
  "org_duration" => "copy from %{duration}"
}
}
mutate {
	convert => ["duration", "float"]
}

```

Any idea why?  
It's not essential, but I'd like to know the reason 🙂

Next inconsequential detail:  
Kibana shows the number with comma again 😕

---

<div class="post-metadata">

**Author:** ![anhlqn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anhlqn/32/5454_2.png) [@anhlqn](https://discuss.elastic.co/u/anhlqn)\
**Post date:** [December 5, 2016, 9:07pm UTC](https://discuss.elastic.co/t/logstash-2-4-grok-mutate-real-with-comma-delimiter/67847/4 "2016-12-05T21:07:37Z")

</div>

> [@caecilie](#):
>
> Any idea why?  
> It's not essential, but I'd like to know the reason

Known issue [Each mutate must be in its own code block · Issue #27 · logstash-plugins/logstash-filter-mutate · GitHub](https://github.com/logstash-plugins/logstash-filter-mutate/issues/27)

> [@caecilie](#):
>
> Next inconsequential detail:  
> Kibana shows the number with comma again

You can change the display format of number fields in Kibana. Go to `Settings > Indices > <your_index>` and change the field format to your need.

---

<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:** [January 2, 2017, 9:07pm UTC](https://discuss.elastic.co/t/logstash-2-4-grok-mutate-real-with-comma-delimiter/67847/5 "2017-01-02T21:07:37Z")

</div>

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