Splunk Search

Returning the bytes of each log

EricLloyd79
Builder

I am trying to have a column returned on a table that shows the bytes of each log entry (and maybe have a cumulative column too but thats irrelevant to this question)
I cannot figure out how to do this. I have read online there is a "bytes_in" field that can be extracted by I am unsure how to do that. I am using custom log files created by our devs here at my job. I see a "bytes" field when I do this query:
index=_internal bytes=*
But I am hoping there is a bytes field that can be extracted from every raw log file created with any custom query (like the mentioned "bytes_in" field above)

Can anyone give me any advice? Thanks!

Tags (2)
0 Karma
1 Solution

aweitzman
Motivator

You want the length of the raw event:

...your search... | eval bytes=len(_raw)

View solution in original post

aweitzman
Motivator

You want the length of the raw event:

...your search... | eval bytes=len(_raw)

yannK
Splunk Employee
Splunk Employee

It is a very close approximation to count the number of characters.
You may see differences between the original file and the events indexed of 1 byte per line on multiline events, as splunk does not index the linebreak of the events.

0 Karma

EricLloyd79
Builder

Thank you yannK.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...