Getting Data In

Parsing Text

kenosborn
New Member

I have the following percent values in indexed logfiles:

Loss=0.00%/0.00% (R/T)

How can I construct a search query that will only look at the percent values before the '/' (aka 'R' or 'Receive)?

Conversely how can I construct a search query that will only look at the percent values after the '/' (aka 'T' or 'Transmit')?

Ultimately I want to create min/max charts for these values...

Thank you!

-Ken

Tags (2)
0 Karma

kristian_kolb
Ultra Champion

That should be fairly simple

sourcetype=your_sourcetype | rex field=Loss "(?<ReceiveLoss>[^%]+)%/(?<TransmitLoss>[^%]+)%"

This would give you two new fields to make charts from.

This type of field extraction has to be specified as part of the search query, but you could make the extraction more 'permanent' by instead adding the extraction to the props.conf stanza for your sourcetype;

[your_sourcetype]
EXTRACT-blah Loss=(?<RecieveLoss>[^%]+)%/(?<TransmitLoss>[^%]+)

Either way, once you have the fields extracted, you could create charts with timechart or chart;

your_search |timechart span=5m max(ReceiveLoss) AS MaxRLoss min(ReceiveLoss) AS MinRLoss max(TransmitLoss) AS MaxTLoss min(TransmitLoss) AS MinTLoss

Then you can save it to a dashboard as a line chart or whatever you like.

Hope this helps,

Kristian

kristian_kolb
Ultra Champion

more updates. /k

0 Karma

kristian_kolb
Ultra Champion

updated and fixed an error. /k

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!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

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 ...