Splunk Search

How to get the Source from one query and search specific variable in that source??

harshal_chakran
Builder

Hi,

I have a sourcetype = ALLXMLDATA, where I have added multiple XML files as data inputs such XMLfile1, XMLfile2 and XMLfile3.

I need to search a specific variable (for e.g. xmlvar2) which might be present in any one of the source file. I am planning to get the source name from this specific variable in one search query and then pass this source name to another search query, to find another variable from it.

Is it possible?? . Please help

Tags (3)
0 Karma

somesoni2
Revered Legend

Try this

index=blah sourcetype=blan-blah [search sourcetype=ALLXMLDATA xmlvar2=* | stats count by source | fields - count] 

The subsearch will give you list of source (xml files) which has xmlvar2 variable (xmlvar2=* is equivalent to isnotnull(xmlvar2)). Then you use this subsearch to get the "source=abc" in your other search.

0 Karma

piebob
Splunk Employee
Splunk Employee

is this the same as the other question you just asked, Harshal? http://answers.splunk.com/answers/116197/how-do-i-get-the-value-of-one-field-if-the-value-of-another... if so, please delete this one.

0 Karma

Ayn
Legend

You should post more specifics about your data and what you want to do with it. Right now I'm confused about what you mean by variables in your data, source etc. Please elaborate.

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...