Splunk Search

subsearch

will4t
Explorer

I have a web_log with _time, src_ip, dst_ip, dst_hostname, url, url_path, file_extension. I tried to run a search on file_extension=swf, then return _time and dst_hostname find out if at the time within 1 minutes if there is any xap and php download. Several trial without success. Really apprecited if someone can help me out.

Tags (1)
0 Karma

Ayn
Legend

One problem here is that _time is considered to be an internal field, and as such won't get picked up by the format command that is implicitly run by the subsearch. So the output will only contain the source parts.

Another problem is that the subsearch will by default only have key=value formatted output, not any equalities like "_time>somevalue". These problems can however be solved using a hack to get the output we want anyway, by creating a field called query which will contain the _time filtering string. query is a special field whose value is returned from the subsearch as-is rather than Splunk adding "query=" before it.

Assuming you have the sourcetype "web_log", the query could look something like this:

sourcetype=web_log file_extension=xap OR file_extension=php [search sourcetype=web_log file_extension=swf | eval query="_time>"._time." AND _time<"._time+60 | fields dst_hostname query]

singhbc
Path Finder

Using the answer above, i am getting the following error.

Error in 'eval' command: Typechecking failed. '+' only takes two strings or two numbers.

index=A sourcetype=X "GET /edge/web/index/home*" [search index=A sourcetype=Y ERR29862 | eval query="_time>"._time." AND _time<"._time+60 | fields corr_id query]

what am i missing?

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...