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
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...