Splunk Search

How do I get only certain value from a log in results ?

kkrish0602
Loves-to-Learn

Is it possible to get a particular value from search results in my final output. I'm having a hard time getting them the way I want them to display in a table.

Search="mpmstats"

Here is the output of my search.

query.png

Out of this I need only bsy value to be displayed in a table as my output like below format

IMG_20210523_154953.png

Still learning 🙂..

Pleas help.... Thanks in Advance

Labels (1)
0 Karma

renjith_nair
Legend

If bsy is not a field, try extracting the field and use it in your search.

E.g.

|rex field=_raw "bsy:\s+(?<bsy>\d+)"|timechart avg(bsy)

 

Test

|makeresults|eval text="mpstats: bsy:  400"
|rex field=text "bsy:\s+(?<Busy>\d+)"

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
Tags (1)
0 Karma

kkrish0602
Loves-to-Learn

<mysearch> | rex field=_raw "bsy:\s+(?<bsy>\d+)"|timechart avg(bsy) is not giving any output

I want my output like

timehost1host2
1bsy valuebsy value
2bsy valuebsy value
0 Karma

yuanliu
SplunkTrust
SplunkTrust


@kkrish0602 wrote:

<mysearch> | rex field=_raw "bsy:\s+(?<bsy>\d+)"|timechart avg(bsy) is not giving any output

I want my output like

timehost1host2
1bsy valuebsy value
2bsy valuebsy value

When giving sample data, desired output, or search code, it is best to use text. Screenshots can be too noisy to be read accurately and difficult to translate into code samples.  According to the screenshot, the above has to output something even if it is not what you were asking.

If the desired output you described is truly in a timechart, you have to also define what stats function to use to obtain "bsy value": is it avg(bsy)? is it max(bsy)? is it values(bsy)? etc. (See Timechart.)  It is possible that you also want to include those events in which the string "bsy" and the value is not separated by colon (:).  In that case, you could use

| rex "bsy:*\s+(?<bsy>\d+)"
| timechart avg(bsy) by host

If the "bsy value" in your desired output is not a statistic but the individual value in each event, the command you are looking for is perhaps xyseries instead of timechart, e.g.,

| rex "bsy:*\s+(?<bsy>\d+)"
| xyseries _time host bsy

 

0 Karma

renjith_nair
Legend

Could you please post some sample events ?

Here is the link to test

https://regex101.com/r/32TXGO/1

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

isoutamo
SplunkTrust
SplunkTrust
You also should add those "| search x y z" directly to the first part of your query without "| search". It's much efficient to reduce the search result set on first phase than add those later on search pipeline.
0 Karma
Get Updates on the Splunk Community!

Developer Spotlight with Brett Adams

In our third Spotlight feature, we're excited to shine a light on Brett—a Splunk consultant, innovative ...

Index This | What can you do to make 55,555 equal 500?

April 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this ...

Say goodbye to manually analyzing phishing and malware threats with Splunk Attack ...

In today’s evolving threat landscape, we understand you’re constantly bombarded with phishing and malware ...