Splunk Search

how to get stats count from 3 multile-value fields

cheriemilk
Path Finder

Hi team,

I have below kind of data in splunk, it contains 3 fields ISRF, DSRF and DSFF.  they are all multi-value fields.

 

2021-10-13 19:26:46,813 ISRF="[fullName,managerFullName,title,userName,division,department,location]" DSRF="[fullName,managerFullName,title,userName,division,department,location]" DSFF="[managerFullName,division,department,location,jobCodereasonForLeaving]"
2021-10-12 19:32:31,504  ISRF="[fullName,managerFullName,userName,division,department,location]" C_DSRF="[fullName,managerFullName,title,userName,division,department,location]" DSFF="[managerFullName,division,department,location,custom05,jobCode,riskOfLoss,impactOfLoss,reasonForLeaving]"   
......
......

 

 

I expect the report like below format:

fieldscount Of ISRFcount Of DSRFcount of DSFF
fullName220
managerFullName222
title120
......   
......   
resonForLeaving001

 

I am trying below queries, and I am blocked how to continue for getting expected format table.

 

<baseQuery>
|eval includeSearchResultField=replace(replace(C_ISRF,"\[",""),"\]",""), 
      defaultSearchResultField=replace(replace(C_DSRF,"\[",""),"\]",""), 
      filterFields=replace(replace(C_DSFF,"\[",""),"\]","") 
|makemv delim="," includeSearchResultField
|makemv delim="," defaultSearchResultField
|makemv delim="," filterFields

 

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

Here is one way to do it - the part before the blank lines just sets up the dummy data

| makeresults
| eval _raw="2021-10-13 19:26:46,813 ISRF=\"[fullName,managerFullName,title,userName,division,department,location]\" DSRF=\"[fullName,managerFullName,title,userName,division,department,location]\" DSFF=\"[managerFullName,division,department,location,jobCodereasonForLeaving]\"
2021-10-12 19:32:31,504  ISRF=\"[fullName,managerFullName,userName,division,department,location]\" DSRF=\"[fullName,managerFullName,title,userName,division,department,location]\" DSFF=\"[managerFullName,division,department,location,custom05,jobCode,riskOfLoss,impactOfLoss,reasonForLeaving]\""
| multikv noheader=t
| table _raw



| extract pairdelim=" ", kvdelim="="
| foreach *
    [| eval <<FIELD>>=split(trim(<<FIELD>>,"[]"),",")]
| fields - _raw
| eval row=1
| untable row field values
| rex max_match=0 field=values "(?<values>\S+)\s*"
| mvexpand values
| stats count by field values
| xyseries values field count
| fillnull value=0

View solution in original post

cheriemilk
Path Finder

@ITWhisperer  Thank you for the solution.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Here is one way to do it - the part before the blank lines just sets up the dummy data

| makeresults
| eval _raw="2021-10-13 19:26:46,813 ISRF=\"[fullName,managerFullName,title,userName,division,department,location]\" DSRF=\"[fullName,managerFullName,title,userName,division,department,location]\" DSFF=\"[managerFullName,division,department,location,jobCodereasonForLeaving]\"
2021-10-12 19:32:31,504  ISRF=\"[fullName,managerFullName,userName,division,department,location]\" DSRF=\"[fullName,managerFullName,title,userName,division,department,location]\" DSFF=\"[managerFullName,division,department,location,custom05,jobCode,riskOfLoss,impactOfLoss,reasonForLeaving]\""
| multikv noheader=t
| table _raw



| extract pairdelim=" ", kvdelim="="
| foreach *
    [| eval <<FIELD>>=split(trim(<<FIELD>>,"[]"),",")]
| fields - _raw
| eval row=1
| untable row field values
| rex max_match=0 field=values "(?<values>\S+)\s*"
| mvexpand values
| stats count by field values
| xyseries values field count
| fillnull value=0
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...