Splunk Search

How to return multivalue result from subsearch that begins with 'stats count'

evelenke
Contributor

Hi, Splunkers

I have pie chart with simple stats by fullname concatenated with bunit ("John Doe; Marketing",...).
Each user may have several assets linked to him in an asset lookup table.
So in driildown table I need to retrieve all IP addresses (hostnames) for 'klicked' user, e.g.:

| stats count| eval person="John Doe; Marketing"  | rex field=person "(?<fullname>[^\;]+)" | lookup asset_lookup fullname as fullname OUTPUT ip host

It only retrieves the first matching result.
How can I get all results?

0 Karma
1 Solution

javiergn
Super Champion

Like this:

| stats count
| eval person="John Doe; Marketing" 
| rex max_match=0 field=person "(?<fullname>[^\;]+)"
| lookup asset_lookup fullname as fullname OUTPUT ip host
| stats values(ip) as ip by fullname

Or this:

| stats count
| eval person="John Doe; Marketing" 
| eval fullname = split(person, ";")
| lookup asset_lookup fullname as fullname OUTPUT ip host
| stats values(ip) as ip by fullname

View solution in original post

0 Karma

evelenke
Contributor

Thanks guys, need to show up what I need - multivalue field ip for my user :

fullname   ip 
John Doe  10.0.0.1
          10.0.0.2
          10.0.0.3
Jane Doe  10.4.1.1
          10.4.1.3

I don't need bunit part in output

0 Karma

javiergn
Super Champion

Two things:

  • Isn't my query below already returning multivalued IP for your users when they match more than 1 IP? If not, have you restricted "Maximum matches" in your lookup advanced configuration to 1 (note this is the default for time-based lookups)?
  • If you also want to summarise by fullname in the same way as you are explaining above, simply append | stats values(ip) as ip by fullname to your query. I've fixed my answers below to reflect this
0 Karma

evelenke
Contributor

That's it! The "Maximum matches" was restricted to 1 (how could I miss this point) , thank you!

0 Karma

javiergn
Super Champion

Like this:

| stats count
| eval person="John Doe; Marketing" 
| rex max_match=0 field=person "(?<fullname>[^\;]+)"
| lookup asset_lookup fullname as fullname OUTPUT ip host
| stats values(ip) as ip by fullname

Or this:

| stats count
| eval person="John Doe; Marketing" 
| eval fullname = split(person, ";")
| lookup asset_lookup fullname as fullname OUTPUT ip host
| stats values(ip) as ip by fullname
0 Karma
Get Updates on the Splunk Community!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...