Splunk Search

Give complete log output on search

YanwuGuTelus
New Member

When I do a search, the search results only show the lines of the logs that are matching my query. Is it possible to show the entire log in the search results? For example, if I search for "FooLogs", the results will correctly show all log files that contain "FooLogs", but only show the line that contains those words. I want to know if I can show the entire contents of the log files that contain the search query.

Tags (1)
0 Karma

koshyk
Super Champion

Have a try

index=foo source=foo.log| reverse | streamstats count(eval(searchmatch("xxxxx"))) AS xyz | reverse | stats list(_raw) AS wholeLogFile by xyz| table wholeLogFile 

An example

index=_internal source="/opt/splunk/var/log/splunk/scheduler.log"| reverse | streamstats count(eval(searchmatch("xxxxx"))) AS xyz | reverse | stats list(_raw) AS wholeLogFile by xyz| table wholeLogFile 
0 Karma

YanwuGuTelus
New Member

It works, but the email i sent to my self started with a figure. how can i get rid of the figure at very beginning?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

You'll have to change your query to something more generic. Look at the output for the "FooLogs" search and find the index and source fields. Use them to compose a new query that will return everything in the same source as FooLogs. For example,

index=foo source=foo.log
---
If this reply helps you, Karma would be appreciated.
0 Karma

YanwuGuTelus
New Member

Thanks, I tried this but I am now getting multiple output lines in the search results from the same log file. I want to have one result per log file that has all the content of the file.

0 Karma

richgalloway
SplunkTrust
SplunkTrust

That wasn't clear from your question. koshyk's answer should do it.

---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...