Splunk
Splunk components
Section titled “Splunk components”Splunk has three main components.
- Indexer: turns raw data uploaded into Splunk into events and places them in an index. Splexicon: Indexer
- Forwarder: a Splunk instance that forwards data to another Splunk instance. More for engineers, but helpful for analysts to know. There are two you’ll meet (Splexicon: Forwarder):
- Universal forwarder: a lightweight agent that just ships raw data. The most common.
- Heavy forwarder: a full Splunk instance that can parse and filter data before sending it on. (The older “light forwarder” is deprecated.)
- Search head: manages search jobs and directs requests to the correct indexer. Splexicon: Search head
Queries
Section titled “Queries”Discovery queries
Section titled “Discovery queries”Discovery queries help analysts find what log data is available before deciding which logs to pivot into.
tstats: replace xxx with your organization’s index naming. tstats docs
| tstats values(sourcetype) AS sourcetypes where index="*xxx*" by indexstats: stats docs
index=xxx*| stats count by index, sourcetypeLogical operators
Section titled “Logical operators”Operators connect search terms. The common ones are AND, OR and IN.
index IN (index-1 index-2) sourcetype IN (sourcetype-name) "item-1" OR "item-2" OR "item-3"index=xxx sourcetype=xxx "item-1" AND "item-2" AND "item-3"- OR broadens the search: results that meet any condition.
- AND narrows it: results must meet all conditions.
- IN is a concise way to match a field against any value in a list.
rex extracts fields using a regular expression. Test patterns with Regex101. .+? matches everything up to the delimiter (,); the ? keeps it from being greedy.
...| rex field=_raw "Is Malware: (?<is_malware>.+?),"Commands
Section titled “Commands”Two kinds of command are worth telling apart. Streaming commands work on each event as it passes, and many can run on the indexers before data reaches you (for example fields). Transforming commands need all the results first and then reshape them (for example stats), so filter as early as you can and put them later in the search.
fields keeps or removes fields. fields docs
index=* sourcetype=*| fields a1, a2, a3| table a1, a2, a3table shows the fields you list as columns. | table * shows every available field. table docs
index=* sourcetype=*| table col1, col2, col3, col4stats summarizes events.
| stats count by src_ip| stats count by src_ip, dest_port| stats values(user_agent) as user_agent count by src| stats latest(_time) as LatestTime by src_ip- values: the de-duplicated values of the field in the brackets
- latest: only the most recent value in each group
- mvindex: picks one value out of a multi-value field
| eval src_port=mvindex(src_port, 0)Send a running search to the background: open the Job menu and choose Send Job to Background.

Expand a macro: a macro is a reusable chunk of SPL. In the search bar, press Ctrl+Shift+E (Windows) or Cmd+Shift+E (Mac) to expand it. Macro docs

One Reverse Look
"A little learning is a dangerous thing." ~ A. Pope
One Reverse Look · Made with ❤ · Your friendly knowledge seeker

