# How to convert gc logs from mb kb to bytes

**URL:** <https://discuss.elastic.co/t/how-to-convert-gc-logs-from-mb-kb-to-bytes/70659>\
**Category:** Logstash\
**Created:** [January 5, 2017, 9:56am UTC](https://discuss.elastic.co/t/how-to-convert-gc-logs-from-mb-kb-to-bytes/70659 "2017-01-05T09:56:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jagadees](https://avatars.discourse-cdn.com/v4/letter/j/c2a13f/32.png) [@jagadees](https://discuss.elastic.co/u/jagadees)\
**Post date:** [January 5, 2017, 9:56am UTC](https://discuss.elastic.co/t/how-to-convert-gc-logs-from-mb-kb-to-bytes/70659/1 "2017-01-05T09:56:45Z")

</div>

filter {  
match =\> { "store" =\> "^%{[@metadata][store\_number]:float}(?INT:before\_memory)[kKmMgGtT])(?INT:after\_memory[kKmMgGtT])(?NOTSPACE:total\_memory[kKmMgGtT])" }  
}

```
mutate {
    add_field => {
        "[@metadata][before_memory][INT:after_memory][NOTSPACE:total_memory]" => "%{INT:before_memory}","%{INT:after_memory}","%{NOTSPACE:total_memory}"
    }
    remove_field => ["[before_memory][INT:after_memory][NOTSPACE:total_memory]" ]
}
if [@metadata][before_memory][INT:after_memory][NOTSPACE:total_memory] == "K" or [@metadata][before_memory][INT:after_memory][NOTSPACE:total_memory] == "K" {
    mutate { add_field => { "[@metadata][store_multiplier]" => 1024 } }
} else if [@metadata][before_memory][INT:after_memory][NOTSPACE:total_memory] == "M" or [@metadata][before_memory][INT:after_memory][NOTSPACE:total_memory] == "M" {
    mutate { add_field => { "[@metadata][store_multiplier]" => 1048576 } }
}
	mutate {
    convert => { "[@metadata][store_multiplier]" => "integer" }
}
```

---

<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:** [January 10, 2017, 6:41am UTC](https://discuss.elastic.co/t/how-to-convert-gc-logs-from-mb-kb-to-bytes/70659/2 "2017-01-10T06:41:28Z")

</div>

I don't believe there's a plugin for this specific purpose, but you can use a ruby filter.

```nohighlight
ruby {
  code => "event.set('fieldname', event.get('fieldname') / event.get('[@metadata][store_multiplier]'))"
}

```

---

<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:** [February 7, 2017, 6:41am UTC](https://discuss.elastic.co/t/how-to-convert-gc-logs-from-mb-kb-to-bytes/70659/3 "2017-02-07T06:41:50Z")

</div>

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