Splunk Search

Splunk DB Connect 1: Is it possible to use an eval before dbquery?

sfatnass
Contributor

Hi everybody,

I want to know if it's possible to use an eval before [dbquery "select blablabla"]

For example:

index="indexA" OR index="indexB" |eval newfield=field1 |stats values(newfield) as newfield values(field2) as field2 by  field1 
[dbquery mydatabase "select field2 from my_table"|fields + field2] 

well i'm trying to get something like that, but splunk said eval is not used properly

I need to record all values of field1 from the index.
The lookup cannot be used for the requested sql.
if anybody have any idea thx

0 Karma

fdi01
Motivator

try lik:

|dbquery mydatabase "select field2 from my_table"|fields + field2|appendcols [ search index="indexA" OR index="indexB" |eval newfield=field1 |stats values(newfield) as newfield values(field2) as field2 by field1] 
0 Karma

sfatnass
Contributor

finally the kvstore resolve my problem thx

0 Karma

sfatnass
Contributor

the dbquery not match with my index
for informaitons i use many dbquery in my request splunk

0 Karma

fdi01
Motivator

ok try like :
|dbquery mydatabase "select field2 from my_table"|fields + field2|appendcols [ search index="indexA" OR index="indexB" |eval newfield=field1] |stats values(newfield) as newfield values(field2) as field2 by field1

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...