Splunk Search

Why doesn't dbquery as a subsearch produce expected results?

NigelCooke
Explorer

I'm having problems with getting a dbquery command to filter the results of a search.

When I run this search :

| dbquery PUMA_T3_ADHOC_REPORTING "select distinct AlertKey from (select AlertKey, update_time from alarm_collector order by update_time asc) where rownum = 1"
| eval PointCode = ALERTKEY
| table PointCode

I get a single result, a field called PointCode with a value of RTOX9891.

When I run this search :

index=ams sourcetype=ams TitleCode=GS TitleIndex=0120 EventType=TSAM*
[search dbquery PUMA_T3_ADHOC_REPORTING "select distinct AlertKey from (select AlertKey, update_time from alarm_collector order by update_time asc) where rownum = 1"
| eval PointCode = ALERTKEY
| table PointCode]

I get no resuts, even though when I run this search :

index=ams sourcetype=ams TitleCode=GS TitleIndex=0120 EventType=TSAM* PointCode=RTOX9891

I get two results.

Should not the second search produce the same results as the third search? The subsearch should filter the outer result set to those having a value for PointCode of RTOX9891.

Any idea why the second search doesn't produce results?

0 Karma
1 Solution

acharlieh
Influencer

Your subsearch should be just [dbquery... ] doing [search dbquery ...] is actually performing a splunk search which isn't quite what you want.

View solution in original post

acharlieh
Influencer

Your subsearch should be just [dbquery... ] doing [search dbquery ...] is actually performing a splunk search which isn't quite what you want.

zarembski
Engager

It worked for me as expected.
Thanks!

0 Karma

NigelCooke
Explorer

Can you add your comment as an answer so that I can accept your answer because it was spot on.

acharlieh
Influencer

Your subsearch should be [dbquery ... ] not [search dbquery ... ]

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 ...