Dashboards & Visualizations

Picking only the first value in search query

aditsss
Motivator

Hi All,

Below is my log data

2020-09-30T05:15:41.732035345Z app_name=api environment=2 ns=ab-c2 integrationType=PULL_GR_FILE_UPLOAD, integrationType=LR_JSON, callbackConfig, integrationType=PUSH_S3_GRS

I made the search query like this:

<query>index=abc ns=ab app_name=ui|stats count by integrationType</query>

The issue I am facing is I am only getting first IntegartionType that is "PULL_GR_FILE_UPLOAD" and its count. Its not taking other integrationType. The log contains 2-3 integration type for a particular date.

Can someone guide me where I am going wrong.

Attached is the screenshot.

 

Labels (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

 

The fact that they appear in selected fields means that they have been extracted. I suspect this extraction is not taking into account that the integrationType may appear multiple times in the event. Either fix the extraction or add it to your query

<query>index=abc ns=ab app_name=ui
| rex max_match=0 "integrationType=(?<integrationType>[^,]+)"
| stats count by integrationType</query>

 

 

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Assuming you have extracted integrationType into a multi-value field, you need to expand this before the stats

<query>index=abc ns=ab app_name=ui|mvexpand integrationType|stats count by integrationType</query>
0 Karma

aditsss
Motivator

@ITWhisperer  @gcusello 

I have not extracted it . It was coming in splunk selected fields.

But its only picking the first.  Not sure where I am going wrong.

Can someone guide me.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

 

The fact that they appear in selected fields means that they have been extracted. I suspect this extraction is not taking into account that the integrationType may appear multiple times in the event. Either fix the extraction or add it to your query

<query>index=abc ns=ab app_name=ui
| rex max_match=0 "integrationType=(?<integrationType>[^,]+)"
| stats count by integrationType</query>

 

 

0 Karma

aditsss
Motivator

@ITWhisperer 

 

It works exactly the way I want. Thank you so much.

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @aditsss,

if you want the most numerous, you can try this:

index=abc ns=ab app_name=ui
| stats count by integrationType
| sort -count
| head 1

Ciao.

Giuseppe

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @aditsss,

if you haven't the fields that you're using in the search, you have to extract all of them: ns, appName and integrationType.

You can use the hint of @ITWhisperer using rex command or you can use the guided web field extractor and then use them.

Ciao.

Giuseppe

 

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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

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