Getting Data In

How do I filter the following data set using a wildcard field name and greater than filter?

splunker1981
Path Finder

Hello experts,

I'm stuck trying to figure out how to filter the following data set to get the results shown below. Any assistance would be greatly appreciated.

Sample results

c_1  f_1    f_2 f_3 f_4 f_5
x001f    1  0     0   0     0
x0883g  1   0     0      0      0
x8834c  2   0     0     0      0
x8832d  3   0     0     0      0
x883kd    n           n             n

I'd like to do a filter by using a field wildcard f_* and > 1 and have it return the complete matching line; like the one below.

    x8834c  2   0     0     0      0
    x8832d  3   0     0     0      0

I tried doing the following, but no luck...

| foreach f_* 
    [ eval total=total + '<<FIELD>>']
    |where total > 1
0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@splunker1981

Can you please add | eval total=0 in you search and try again?

My Sample Search

| makeresults 
| eval _raw="
 c_1     f_1    f_2    f_3    f_4    f_5
 x001f     1    0      0      0      0
 x0883g    1    0      0      0      0
 x8834c    2    0      0      0      0
 x8832d    3    0      0      0      0
" 
| multikv | eval total=0
| foreach f_* 
    [ eval total=total + '<<FIELD>>'] 
| where total > 1

Thanks

0 Karma

splunker1981
Path Finder

Thanks for the response! The problem is that it's adding up all the values which is NOT what I want. I just want to iterate through each of the f_* fields, see if the value for each of those fields is > 1 (independent of one another) and print those rows if any of the f_* have a value > 1

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@splunker1981

Can you please try this?

YOUR_SEARCH | eval status=0
 | foreach f_* 
     [ eval status=if('<<FIELD>>' > 1 AND status==0,1,status) ] | where status=1

Sample:

| makeresults 
 | eval _raw="
  c_1     f_1    f_2    f_3    f_4    f_5
  x001f     1    0      0      0      0
  x0883g    1    0      0      0      0
  x8834c    2    0      0      0      0
  x8832d    3    0      0      0      0
 " 
 | multikv | eval status=0
 | foreach f_* 
     [ eval status=if('<<FIELD>>' > 1 AND status==0,1,status) ] | where status=1
0 Karma

splunker1981
Path Finder

Still not working when I run against my data. I did notice that using your command I get the desired results. when I specifically filter using |search for the 10 results that should match, then the search works. But if I remember the |where I only get 1 match....

0 Karma

kamlesh_vaghela
SplunkTrust
SplunkTrust

@splunker1981

Apology for a delay in reply. Can you please share more information regarding your search and samples?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Your Feedback. Our Roadmap. Visit the PX Feedback Booth at .conf26

You use Splunk every day, come and help shape what's next.  Save Your Seat: Product-Focused Sessions at ...

Agentic SOC Triage: Investigating Splunk ES Notables with MCP Server and a Local LLM

The Problem: Too Many Alerts, Too Little Context Security operations teams running Splunk Enterprise Security ...

Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas

Watch Now Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas     Do you ever feel ...