Search Queries
Useful search commands
Count by tag you are searching for like "Message" will bring a count of like messages
Rex is regex that you can replace a string like below replace a space with a underscore
Pulls data from fields and organizes it into a table view
lookup a uploaded csv table by file name
Find items like
Compare IP data in file with Splunk logs
lookup c2cisp.csv ip - calls the file and uses the ip column
matches the ip to the the data set d_ip
outputs the matched in a var named c2cisp
Find IPs that are not in the csv or 123.123.123.123
lookup Resources
For reference: the docs have a page for each command: lookup, inputlookup, and outputlookup.
In short:
lookup
adds data to each existing event in your result set based on a field existing in the event matching a value in the lookupinputlookup
takes the the table of the lookup and creates new events in your result set (either created completely or added to a prior result set)outputlookup
takes the current event set and writes it to a CSV or KVStore.
As an aside, when getting started with SPL commands, the Quick Reference Guide is the holy grail IMO for learning all about Splunk key concepts and common commands, along with different examples. Make sure you've got this one in your back pocket, as well as the Search Reference Docs. Yes, you can lookup two tables in the came command. You can even join the two tables together. It really depends on what you're trying to do with the lookup (whether you're trying to use multiple inputlookup calls, or multiple lookup calls).
The former requires the use of append or join:
| inputlookup lookup1| append [|inputlookup lookup2]| join ip [|inputlookup lookup3]
The latter is just sequential:
index=<index> sourcetype=<sourcetype> |lookup lookup1 ip |lookup lookup2 host OR |inputlookup3 |lookup lookup1 ip |lookup lookup2 host
Using Sort
Using where
Using maps with Location of IP
Cluster map
Choropleth Map
To add multiple lookup files to a search, this should work for Cluster map and Choropleth Map
You can just stack the lookups
IP manipulation removing port
rex
command:Extracts the IP address portion from the
field_with_ip_port
field.The regex
(?<ip>\d{1,3}(\.\d{1,3}){3})
captures any valid IPv4 address.
stats count by ip
:Groups the results by the extracted
ip
field.Counts the occurrences of each unique IP address.
Count the location of a IP
Last updated