A Splunk search consists of one or more data-generating commands and their arguments, which can include literal keywords, wildcards, Boolean expressions, modifier name and value pairs, and subsearches. The generated data (search results) can then be used as inputs into other search commands in a search pipeline.
Splunk search commands are categorized by the type of operations they perform. You've already seen some examples of data generating commands. There are also commands that allow you to:
The following examples will demonstrate some of these capabilities. Refer to Search Commands for the complete list.
ReportReport commands, such as timechart, stats, top, and rare, summarize your results in the report window.
timecharttimechart returns statistics bucketed by time and is good for driving line charts. Try these examples.
Count of deny events graphed by time.
Sum of bytes for GET requests:
Average bytes by method:
stats provides summary calculations by any field.
Total bytes sent by destination.
Let's get the top denied source IP addresses. Try it with a column graph.
rareYou can also get the 10 least common source IPs (by using rare).
TransformTransform commands, such as transaction and diff , allow you manipulate the fields and values in your search results.
transactionThis search takes events from the access logs and creates a transaction from events that share the same clientip value that occurred within 5 minutes of each other (within a 3 hour time span).
diffSearch for errors in syslog and diff the first and third results.
Compare the host field of the last search.
You can modify the order of your results based on different fields.
sortUse the sort command to re-order the top 100 src field values of netscreen deny events.
FilterYou can define constraints to modify your search results.
setReturn all URLs that have 404 errors but no 303 errors (using set).
Use the regex command to filter results out of your search results. Specify a regular expression in regex to remove results that do not match.
Note: if you want to use the "or" ("|") command in a regex argument, the whole regular expression must be surrounded by quotes (ie. regex "<expression>").
The following example gets sendmail events that contain IP addresses in the non-routable class A (10.0.0.0/8).
Note: The regex command supports inclusion of PCREs (Perl Compatible Regular Expressions).
EvaluateYou can perform operations directly on your data while searching.
fieldsUse the fields command to specify the particular fields you want to see in your results. Here we will display only the src and dst fields of the sampledata netscreen deny events.
Add a comparisonLet's go back to our top source IP addresses and filter for ones with more than 5 denies by using a logical comparison in the search command.
Refer to the Search Syntax for more information on Comparison Operators.
Use subsearchesNow we're going to put it all together by doing another search to find which of the actions with more than 2 500 http status codes also had 200 successes.
Comments
No comments have been submitted.