# Cant parse logs with - in bytes field

**URL:** <https://discuss.elastic.co/t/cant-parse-logs-with-in-bytes-field/321281>\
**Category:** Logs\
**Created:** [December 15, 2022, 9:46am UTC](https://discuss.elastic.co/t/cant-parse-logs-with-in-bytes-field/321281 "2022-12-15T09:46:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bill210kouk](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@bill210kouk](https://discuss.elastic.co/u/bill210kouk)\
**Post date:** [December 15, 2022, 9:46am UTC](https://discuss.elastic.co/t/cant-parse-logs-with-in-bytes-field/321281/1 "2022-12-15T09:46:37Z")

</div>

Hello!

I facing an issue with my grok format pattern even though i managed to change the type of the bytes log field to numbers (this type will be used for better Kibana visualizations) some of logs have the bytes field filled with "-". So that they fail .  
How will i be able to change the "-" into 0 so that i can finish my visuals.

Thanks in Advance.  
Have a nice Day!

---

<div class="post-metadata">

**Author:** ![dadiasish](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadiasish/32/114221_2.png) [@dadiasish](https://discuss.elastic.co/u/dadiasish)\
**Post date:** [December 15, 2022, 10:11am UTC](https://discuss.elastic.co/t/cant-parse-logs-with-in-bytes-field/321281/2 "2022-12-15T10:11:31Z")

</div>

You can alter the value or replace while ingestion itself using mutate filter in Logstash.

Try it out. This URL will give you some idea.

> **[Mutate filter plugin | Logstash Reference \[8.5\] | Elastic](https://www.elastic.co/guide/en/logstash/current/plugins-filters-mutate.html#plugins-filters-mutate-convert)**

---

<div class="post-metadata">

**Author:** ![bill210kouk](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@bill210kouk](https://discuss.elastic.co/u/bill210kouk)\
**Post date:** [December 15, 2022, 10:26am UTC](https://discuss.elastic.co/t/cant-parse-logs-with-in-bytes-field/321281/3 "2022-12-15T10:26:24Z")

</div>

Thank you for the immediate respone. My configuration consists of just Elastic and Kibana

Is there any way converting it to 0 without Logstash?

Thanks!!

---

<div class="post-metadata">

**Author:** ![dadiasish](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadiasish/32/114221_2.png) [@dadiasish](https://discuss.elastic.co/u/dadiasish)\
**Post date:** [December 15, 2022, 10:35am UTC](https://discuss.elastic.co/t/cant-parse-logs-with-in-bytes-field/321281/4 "2022-12-15T10:35:37Z")

</div>

One way of doing it is via processor's in Elasticsearch ingest pipelines.

Below is the URL which can help you.

> **[Script processor | Elasticsearch Guide \[8.5\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/script-processor.html)**

---

<div class="post-metadata">

**Author:** ![bill210kouk](https://avatars.discourse-cdn.com/v4/letter/b/d9b06d/32.png) [@bill210kouk](https://discuss.elastic.co/u/bill210kouk)\
**Post date:** [December 15, 2022, 1:43pm UTC](https://discuss.elastic.co/t/cant-parse-logs-with-in-bytes-field/321281/5 "2022-12-15T13:43:30Z")

</div>

Have tried this one  
"set" : {  
"if" : "ctx.bytes == '-'",  
"field" : "bytes",  
"value" : 0  
},

And it didnt work...in my kibana index pattern it shows a number field though all "-" fail to be parsed.

is there any other approach or did my approach was wrong?

Thanks!

---

<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 12, 2023, 1:44pm UTC](https://discuss.elastic.co/t/cant-parse-logs-with-in-bytes-field/321281/6 "2023-01-12T13:44:08Z")

</div>

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