Splunk Search

splunk search statement using keyword from input box text string

mia
Explorer

the large size logs like as below

it's not a regular json data, therefore need to using rex to get fields

A logs have name and uid

B and C logs have uid and oid

the dashboard accept input name, it allow multiple name with comma

then using the name to find the uid and figure out the related uid and oid data from B logs and exclude from c logs

so, I don't know how to 

1. in a search statement substitute using the value of users be a keyword

2. combine the field data with comma for using  function search data in (...) 

 

Thanks.

--

for example:

A logs:
... x1 ...uid=123...
... y2 ...uid=456...
... z3 ...uid=789...

B logs:
.... oid=989 ...uid=123 ...
.... oid=566 ...uid=456 ...
.... oid=486 ...uid=789 ...

C logs:
...cancel_order... oid=989 ...uid=123 ...
...cancel_order... oid=566 ...uid=456 ...
...cancel_order... oid=486 ...uid=789 ...

a dashboard has a input box text: users, and user can input multiple users with comma
the value of users will be like "x1,z3"

I wont to put the value in a search statement
such us

| makeresults
| eval users="x1,z3"

| eval names=replace(users, ",", " OR ")    =>excepted result: x1 OR z3
| search source="alog" $names$     => Substitute the names value into keyword
| rex "name=(?<name>\S+)"
| rex "uid=(?<uid>\d+)"
| table name,uid
| join type=left max=0 uid
[
source="blog" 
| rex "uid=(?<uid>\d+)"
| rex "oid=(?<oid>\d+)"
| search uid in (uids)    => uids combin the uid values with comma ex: (123,456,789)
| table uid,oid
]
| join type=left max=0 oid
[
source="clog" cancel_order
| rex "uid=(?<uid>\d+)"
| rex "oid=(?<oid>\d+)"
| search uid in (uids)    => uids combin the uid values with comma ex: (123,456,789)
| table uid,oid,status
]
| where isnull(status)
| stats count(oid) by name

Labels (1)
0 Karma
Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Enhance Security Operations with Automated Threat Analysis in the Splunk EcosystemAre you leveraging ...

Splunk Developers: Go Beyond the Dashboard with These .Conf25 Sessions

  Whether you’re building custom apps, diving into SPL2, or integrating AI and machine learning into your ...

Index This | How do you write 23 only using the number 2?

July 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...