Splunk Tutorials: Splunk Commands Reference


Here’s an updated table with example queries that utilize the respective Splunk commands:

Splunk CommandDescriptionExample Query (Apache Log)
searchRetrieves events that match specific search criteria.search index=apache_logs status=200 error
statsCalculates aggregate statistics for fields.stats count by method index=apache_logs
tableDisplays search results in a tabular format.table method, status, bytes index=apache_logs
timechartGenerates a chart showing values over time.timechart count by method index=apache_logs
whereFilters events based on specified conditions.where status=200 index=apache_logs
evalCreates new fields or modifies existing ones.eval response_time=duration/1000 index=apache_logs
rexExtracts fields from event data using regular expressions.rex field=request "(?<page>[^/]+)$" index=apache_logs
topDisplays the top values for a specified field.top clientip limit=10 index=apache_logs
dedupRemoves duplicate events based on specified fields.dedup clientip index=apache_logs
transactionGroups events together based on a common field value.transaction clientip maxspan=1h index=apache_logs
renameRenames fields in search results.rename status AS response_code index=apache_logs
sortSorts events based on specified fields.sort -bytes index=apache_logs
chartGenerates various types of charts based on search results.chart count by method index=apache_logs
spathExtracts structured fields from event data.spath input=_raw path=request.url index=apache_logs
makemvConverts a delimited field into a multivalue field.makemv delim="," user_agents index=apache_logs
fillnullReplaces null or missing values with specified default values.fillnull value="N/A" index=apache_logs
geostatsGenerates geospatial statistics and visualizations.geostats count by clientip index=apache_logs
appendCombines the results of multiple searches into a single result set.append [search index=other_logs] index=apache_logs

Splunk CommandDescription
addcoltotalsAdds a row at the bottom of the search results table with totals for numerical fields.
addinfoAdds information about search performance and resource usage to the search results.
addtotalsAdds a row at the bottom of the search results table with totals for specified fields.
anomaliesDetects anomalies or unusual patterns in time series data.
anomalousvalueDetects anomalies or unusual patterns in a specific field.
appendCombines the results of multiple searches into a single result set.
appendcolsCombines fields from multiple searches into a single result set.
auditTracks access to search results and other Splunk platform features.
binBins numerical values into specific ranges or intervals.
bucketGroups events based on time intervals.
chartGenerates various types of charts based on search results.
clusterGroups events based on similarity and identifies outliers.
collectSends search results to a summary index.
colortestDisplays a color test chart.
concurrencyMeasures the concurrency of events over time.
contingencyCalculates the contingency table for two fields.
convertConverts field values from one data type to another.
corrCalculates the correlation coefficient between two fields.
dbinspectInspects the structure and content of a database.
dbxqueryExecutes an SQL query against a database.
dedupRemoves duplicate events based on specified fields.
deleteDeletes events from a search index.
deltaCalculates the difference between consecutive events.
diffCompares events between two searches and displays the differences.
erexExtracts fields using a custom regular expression.
erowcolPerforms a rolling calculation on a field based on a sliding window.
eventcountCounts events based on specified conditions.
eventstatsCalculates statistics on all events and adds them to each event.
extractExtracts fields from event data using delimiters or regular expressions.
fieldformatFormats the display of field values.
fieldsSelects specific fields to display in search results.
filldownCopies the value from the previous non-null event into subsequent events.
fillnullReplaces null or missing values with specified default values.
fileboostAdjusts the search ranking for events in specific files.
filesmetaProvides metadata information about files.
fingerprintGenerates a unique identifier for each event based on specified fields.
formatFormats the display of search results.
fromSpecifies the source index or source search for a subsearch.
geodistanceCalculates the distance between geographical coordinates.
geostatsGenerates geospatial statistics and visualizations.
headRetrieves the first N events from search results.
highlightApplies syntax highlighting to search results.
historyDisplays search command history.
iconifyConverts field values into icons based on conditions.
inputcsvReads

This topic links to the Splunk Enterprise Search Reference for each search command.

CommandDescriptionSee also
abstractProduces a summary of each search result.highlight
accumKeeps a running total of the specified numeric field.autoregress, delta, trendline, streamstats
addcoltotalsComputes an event that contains sum of all numeric fields for previous events.addtotalsstats
addinfoAdd fields that contain common information about the current search.search
addtotalsComputes the sum of all numeric fields for each result.addcoltotalsstats
analyzefieldsAnalyze numerical fields for their ability to predict another discrete field.anomalousvalue
anomaliesComputes an “unexpectedness” score for an event.anomalousvalue, cluster, kmeans, outlier
anomalousvalueFinds and summarizes irregular, or uncommon, search results.analyzefields, anomalies, cluster, kmeans, outlier
appendAppends subsearch results to current results.appendcols, appendcsv, join, set
appendcolsAppends the fields of the subsearch results to current results, first results to first result, second to second, etc.append, appendcsv, join, set
appendpipeAppends the result of the subpipeline applied to the current result set to results.appendappendcolsjoinset
arulesFinds association rules between field values.associatecorrelate
associateIdentifies correlations between fields.correlate, contingency
auditReturns audit trail information that is stored in the local audit index.
autoregressSets up data for calculating the moving average.accum, autoregress, delta, trendline, streamstats
bin, discretizePuts continuous numerical values into discrete sets.chart, timechart
bucketdirReplaces a field value with higher-level grouping, such as replacing filenames with directories.cluster, dedup
chartReturns results in a tabular output for charting. See Functions for stats, chart, and timechart in the Splunk Enterprise Search Reference.timechart
clusterClusters similar events together.anomalies, anomalousvalue, cluster, kmeans, outlier
concurrencyUses a duration field to find the number of “concurrent” events for each event.timechart
contingency, counttable, ctableBuilds a contingency table for two fields.associate, correlate
convertConverts field values into numerical values.eval
correlateCalculates the correlation between different fields.associate, contingency
dbinspectReturns information about the specified index.
dedupRemoves subsequent results that match a specified criteria.uniq
deltaComputes the difference in field value between nearby results.accum, autoregress, trendline, streamstats
diffReturns the difference between two search results.
erexAllows you to specify example or counter example values to automatically extract fields that have similar values.extractkvformmultikvregexrexxmlkv
evalCalculates an expression and puts the value into a field. See Functions for eval and where in the Splunk Enterprise Search Reference.where
eventcountReturns the number of events in an index.dbinspect
eventstatsAdds summary statistics to all search results.stats
extract, kvExtracts field-value pairs from search results.kvform, multikv, xmlkv, rex
fieldformatExpresses how to render a field at output time without changing the underlying value.eval, where
fieldsRemoves fields from search results.
fieldsummaryGenerates summary information for all or a subset of the fields.af, anomalies, anomalousvalue, stats
filldownReplaces NULL values with the last non-NULL value.fillnull
fillnullReplaces null values with a specified value.
findtypesGenerates a list of suggested event types.typer
foreachRun a templatized streaming subsearch for each field in a wildcarded field list.eval
formatTakes the results of a subsearch and formats them into a single result.
fromRetrieves data from a dataset, such as a data model dataset, a CSV lookup, a KV Store lookup, a saved search, or a table dataset.
gaugeTransforms results into a format suitable for display by the Gauge chart types.
gentimesGenerates time-range results.
geostatsGenerate statistics which are clustered into geographical bins to be rendered on a world map.statsxyseries
headReturns the first number n of specified results.reverse, tail
highlightCauses Splunk Web to highlight specified terms.
historyReturns a history of searches formatted as an events list or as a table.search
inputAdds sources to Splunk or disables sources from being processed by Splunk.
inputcsvLoads search results from the specified CSV file.loadjob, outputcsv
iplocationExtracts location information from IP addresses.
joinSQL-like joining of results from the main results pipeline with the results from the subpipeline.selfjoin, appendcols
kmeansPerforms k-means clustering on selected fields.anomalies, anomalousvalue, cluster, outlier
kvformExtracts values from search results, using a form template.extract, kvform, multikv, xmlkv, rex
loadjobLoads events or results of a previously completed search job.inputcsv
localizeReturns a list of the time ranges in which the search results were found.map, transaction
makecontinuousMakes a field that is supposed to be the x-axis continuous (invoked by chart/timechart)chart, timechart
makemvChange a specified field into a multivalued field during a search.mvcombine, mvexpand, nomv
mapA looping operator, performs a search over each search result.
mcollectConverts search results into metric data and inserts the data into a metric index on the search head.collectmeventcollect
metadataReturns a list of source, sourcetypes, or hosts from a specified index or distributed search peer.dbinspect
metasearchRetrieves event metadata from indexes based on terms in the logical expression.metadatasearch
meventcollectConverts search results into metric data and inserts the data into a metric index on the indexers.collectmcollect
mstatsCalculates statistics for the measurement, metric_name, and dimension fields in metric indexes.stats
multikvExtracts field-values from table-formatted events.
multisearchRun multiple streaming searches at the same time.append, join
mvcombineCombines events in search results that have a single differing field value into one result with a multivalue field of the differing field.mvexpand, makemv, nomv
mvexpandExpands the values of a multivalue field into separate events for each value of the multivalue field.mvcombine, makemv, nomv
nomvChanges a specified multivalued field into a single-value field at search time.makemv, mvcombine, mvexpand
outlierRemoves outlying numerical values.anomalies, anomalousvalue, cluster, kmeans
outputcsvOutputs search results to a specified CSV file.inputcsv, outputtext
outputtextOuputs the raw text field (_raw) of results into the _xml field.outputtext
predictEnables you to use time series algorithms to predict future values of fields.x11
rangemapSets RANGE field to the name of the ranges that match.
rareDisplays the least common values of a field.stats, top
regexRemoves results that do not match the specified regular expression.rexsearch
reltimeConverts the difference between ‘now’ and ‘_time’ to a human-readable value and adds adds this value to the field, ‘reltime’, in your search results.convert
renameRenames a specified field; wildcards can be used to specify multiple fields.
replaceReplaces values of specified fields with a specified new value.
restAccess a REST endpoint and display the returned entities as search results.
returnSpecify the values to return from a subsearch.format, search
reverseReverses the order of the results.head, sort, tail
rexSpecify a Perl regular expression named groups to extract fields while you search.extract, kvform, multikv, xmlkv, regex
rtorderBuffers events from real-time search to emit them in ascending time order when possible.
savedsearchReturns the search results of a saved search.
script, runRuns an external Perl or Python script as part of your search.
scrubAnonymizes the search results.
searchSearches Splunk indexes for matching events.
searchtxnFinds transaction events within specified search constraints.transaction
selfjoinJoins results with itself.join
sendemailEmails search results to a specified email address.
setPerforms set operations (union, diff, intersect) on subsearches.append, appendcols, join, diff
setfieldsSets the field values for all results to a common value.evalfillnullrename
sortSorts search results by the specified fields.reverse
spathProvides a straightforward means for extracting fields from structured data formats, XML and JSON.xpath
statsProvides statistics, grouped optionally by fields. See Functions for stats, chart, and timechart in the Splunk Enterprise Search Reference.eventstats, top, rare
strcatConcatenates string values.
streamstatsAdds summary statistics to all search results in a streaming manner.eventstats, stats
tableCreates a table using the specified fields.fields
tagsAnnotates specified fields in your search results with tags.eval
tailReturns the last number n of specified results.head, reverse
timechartCreate a time series chart and corresponding table of statistics. See Functions for stats, chart, and timechart in the Splunk Enterprise Search Reference.chart, bucket
topDisplays the most common values of a field.rare, stats
transactionGroups search results into transactions.
transposeReformats rows of search results as columns.
trendlineComputes moving averages of fields.timechart
typeaheadReturns typeahead information on a specified prefix.
typerCalculates the eventtypes for the search results.typelearner
uniqRemoves any search that is an exact duplicate with a previous result.dedup
untableConverts results from a tabular format to a format similar to stats output. Inverse of xyseries and maketable.
wherePerforms arbitrary filtering on your data. See Functions for eval and where in the Splunk Enterprise Search Reference.eval
x11Enables you to determine the trend in your data by removing the seasonal pattern.predict
xmlkvExtracts XML key-value pairs.extract, kvform, multikv, rex
xmlunescapeUnescapes XML.
xpathRedefines the XML path.
xyseriesConverts results into a format suitable for graphing.

Search commands by category

The search commands that make up the Splunk Light search processing language are a subset of the Splunk Enterprise search commands. The tables below list the commands that make up the Splunk Light search processing language and is categorized by their usage. Some commands fit into more than one category based on the options that you specify.

This topic links to the Splunk Enterprise Search Reference for each search command.

Correlation

These commands can be used to build correlation searches.

CommandDescription
appendAppends subsearch results to current results.
appendcolsAppends the fields of the subsearch results to current results, first results to first result, second to second, etc.
appendpipeAppends the result of the subpipeline applied to the current result set to results.
arulesFinds association rules between field values.
associateIdentifies correlations between fields.
contingency, counttable, ctableBuilds a contingency table for two fields.
correlateCalculates the correlation between different fields.
diffReturns the difference between two search results.
joinSQL-like joining of results from the main results pipeline with the results from the subpipeline.
selfjoinJoins results with itself.
setPerforms set operations (union, diff, intersect) on subsearches.
statsProvides statistics, grouped optionally by fields. See Functions for stats, chart, and timechart in the Splunk Enterprise Search Reference.
transactionGroups search results into transactions.

Data and indexes

These commands can be used to learn more about your data and manager your data sources.

View data

These commands return information about the data you have in your indexes. They do not modify your data or indexes in any way.

CommandDescription
auditReturns audit trail information that is stored in the local audit index.
dbinspectReturns information about the specified index.
eventcountReturns the number of events in an index.
metadataReturns a list of source, sourcetypes, or hosts from a specified index or distributed search peer.
typeaheadReturns typeahead information on a specified prefix.

Manage data

These are some commands you can use to add data sources to or delete specific data from your indexes.

CommandDescription
deleteDelete specific events or search results.
inputAdds sources to Splunk or disables sources from being processed by Splunk.

Fields

These are commands you can use to add, extract, and modify fields or field values. The most useful command for manipulating fields is eval and its functions.

Add fields

Use these commands to add new fields.

CommandDescription
accumKeeps a running total of the specified numeric field.
addinfoAdd fields that contain common information about the current search.
addtotalsComputes the sum of all numeric fields for each result.
deltaComputes the difference in field value between nearby results.
evalCalculates an expression and puts the value into a field. See Functions for eval and where in the Splunk Enterprise Search Reference.
iplocationAdds location information, such as city, country, latitude, longitude, and so on, based on IP addresses.
multikvExtracts field-values from table-formatted events.
rangemapSets RANGE field to the name of the ranges that match.
strcatConcatenates string values and saves the result to a specified field.

Extract fields

These commands provide different ways to extract new fields from search results.

CommandDescription
erexAllows you to specify example or counter example values to automatically extract fields that have similar values.
extract, kvExtracts field-value pairs from search results.
kvformExtracts values from search results, using a form template.
rexSpecify a Perl regular expression named groups to extract fields while you search.
spathProvides a straightforward means for extracting fields from structured data formats, XML and JSON.
xmlkvExtracts XML key-value pairs.

Modify fields and field values

Use these commands to modify fields or their values.

CommandDescription
convertConverts field values into numerical values.
filldownReplaces NULL values with the last non-NULL value.
fillnullReplaces null values with a specified value.
makemvChange a specified field into a multivalued field during a search.
nomvChanges a specified multivalued field into a single-value field at search time.
reltimeConverts the difference between ‘now’ and ‘_time’ to a human-readable value and adds adds this value to the field, ‘reltime’, in your search results.
renameRenames a specified field; wildcards can be used to specify multiple fields.
replaceReplaces values of specified fields with a specified new value.

Find anomalies

These commands are used to find anomalies in your data. Either search for uncommon or outlying events and fields or cluster similar events together.

CommandDescription
analyzefields, afAnalyze numerical fields for their ability to predict another discrete field.
anomaliesComputes an “unexpectedness” score for an event.
anomalousvalueFinds and summarizes irregular, or uncommon, search results.
clusterClusters similar events together.
kmeansPerforms k-means clustering on selected fields.
outlierRemoves outlying numerical values.
rareDisplays the least common values of a field.

Geoip and location

These commands add geographical information to your search results.

CommandDescription
iplocationReturns location information, such as city, country, latitude, longitude, and so on, based on IP addresses.
geostatsGenerate statistics which are clustered into geographical bins to be rendered on a world map.

Metrics

These commands work with metrics data.

CommandDescription
mcollectConverts events into metric data points and inserts the data points into a metric index on the search head.
meventcollectConverts events into metric data points and inserts the data points into a metric index on indexer tier.
mstatsCalculates visualization-ready statistics for the measurementmetric_name, and dimension fields in metric indexes.

Prediction and trending

These commands predict future values and calculate trendlines that can be used to create visualizations.

CommandDescription
predictEnables you to use time series algorithms to predict future values of fields.
trendlineComputes moving averages of fields.
x11Enables you to determine the trend in your data by removing the seasonal pattern.

Reports

These commands are used to build transforming searches. These commands return statistical data tables required for charts and other kinds of data visualizations.

CommandDescription
addtotalsComputes the sum of all numeric fields for each result.
bin, discretizePuts continuous numerical values into discrete sets.
chartReturns results in a tabular output for charting. See Statistical and charting functions in the Splunk Enterprise Search Reference.
contingency, counttable, ctableBuilds a contingency table for two fields.
correlateCalculates the correlation between different fields.
eventcountReturns the number of events in an index.
eventstatsAdds summary statistics to all search results.
gaugeTransforms results into a format suitable for display by the Gauge chart types.
makecontinuousMakes a field that is supposed to be the x-axis continuous (invoked by chart/timechart)
mstatsCalculates statistics for the measurement, metric_name, and dimension fields in metric indexes.
outlierRemoves outlying numerical values.
rareDisplays the least common values of a field.
statsProvides statistics, grouped optionally by fields. See Statistical and charting functions in the Splunk Enterprise Search Reference.
streamstatsAdds summary statistics to all search results in a streaming manner.
timechartCreate a time series chart and corresponding table of statistics. See Statistical and charting functions in the Splunk Enterprise Search Reference.
topDisplays the most common values of a field.
trendlineComputes moving averages of fields.
untableConverts results from a tabular format to a format similar to stats output. Inverse of xyseries and maketable.
xyseriesConverts results into a format suitable for graphing.

Results

These commands can be used to manage search results. For example, you can append one set of results with another, filter more events from the results, reformat the results, and so on.

Alerting

Use this command to email the results of a search.

CommandDescription
sendemailEmails search results, either inline or as an attachment, to one or more specified email addresses.

Append

Use these commands to append one set of results with another set or to itself.

CommandDescription
appendAppends subsearch results to current results.
appendcolsAppends the fields of the subsearch results to current results, first results to first result, second to second, and so on.
joinSQL-like joining of results from the main results pipeline with the results from the subpipeline.
selfjoinJoins results with itself.

Filter

Use these commands to remove more events or fields from your current results.

CommandDescription
dedupRemoves subsequent results that match a specified criteria.
fieldsRemoves fields from search results.
mvcombineCombines events in search results that have a single differing field value into one result with a multivalue field of the differing field.
regexRemoves results that do not match the specified regular expression.
searchtxnFinds transaction events within specified search constraints.
tableCreates a table using the specified fields.
uniqRemoves any search that is an exact duplicate with a previous result.
wherePerforms arbitrary filtering on your data. See Evaluation functions in the Splunk Enterprise Search Reference.

Format

Use these commands to reformat your current results.

CommandDescription
untableConverts results from a tabular format to a format similar to stats output. Inverse of xyseries and maketable.
xyseriesConverts results into a format suitable for graphing.

Generate

Use these commands to generate or return events.

CommandDescription
gentimesReturns results that match a time-range.
loadjobLoads events or results of a previously completed search job.
mvexpandExpands the values of a multivalue field into separate events for each value of the multivalue field.
savedsearchReturns the search results of a saved search.
searchSearches Splunk indexes for matching events. This command is implicit at the start of every search pipeline that does not begin with another generating command.

Group

Use these commands to group or classify the current results.

CommandDescription
clusterClusters similar events together.
kmeansPerforms k-means clustering on selected fields.
mvexpandExpands the values of a multivalue field into separate events for each value of the multivalue field.
transactionGroups search results into transactions.
typerCalculates the eventtypes for the search results.

Reorder

Use these commands to change the order of the current search results.

CommandDescription
headReturns the first number n of specified results.
reverseReverses the order of the results.
sortSorts search results by the specified fields.
tailReturns the last number N of specified results

Read

Use these commands to read in results from external files or previous searches.

CommandDescription
inputcsvLoads search results from the specified CSV file.
loadjobLoads events or results of a previously completed search job.

Write

Use these commands to define how to output current search results.

CommandDescription
mcollectConverts events into metric data points and inserts the data points into a metric index on the search head.
meventcollectConverts events into metric data points and inserts the data points into a metric index on indexer tier.
outputcsvOutputs search results to a specified CSV file.
outputtextOuputs the raw text field (_raw) of results into the _xml field.
sendemailEmails search results, either inline or as an attachment, to one or more specified email addresses.

Search

CommandDescription
mapA looping operator, performs a search over each search result.
searchSearches Splunk indexes for matching events. This command is implicit at the start of every search pipeline that does not begin with another generating command.
sendemailEmails search results, either inline or as an attachment, to one or more specified email addresses.

Subsearch

These are commands that you can use with subsearches.

CommandDescription
appendAppends subsearch results to current results.
appendcolsAppends the fields of the subsearch results to current results, first results to first result, second to second, and so on.
appendpipeAppends the result of the subpipeline applied to the current result set to results.
formatTakes the results of a subsearch and formats them into a single result.
joinSQL-like joining of results from the main results pipeline with the results from the subpipeline.
returnSpecify the values to return from a subsearch.
setPerforms set operations (union, diff, intersect) on subsearches.

Time

Use these commands to search based on time ranges or add time information to your events.

CommandDescription
gentimesReturns results that match a time-range.
localizeReturns a list of the time ranges in which the search results were found.
reltimeConverts the difference between ‘now’ and ‘_time’ to a human-readable value and adds adds this value to the field, ‘reltime’, in your search results.

SPL2 Command Quick Reference

The following commands are supported in SPL2. Use the links in the table to see the command syntax, examples, and usage information.

CommandDescriptionExample
binPuts continuous numerical values into discrete sets, or bins.Example: Return the average for a field for a specific time span. Bin the search results using a 5 minute time span on the _time field. Return the average thruput of each host for each 5 minute time span....| bin span=5m _time | stats avg(thruput) by _time, host
branchProcesses one set of events or search results, in parallel, in two or more branches. Each branch must end with the into command.Example: Read the events in the main index dataset into memory one time. Process the events in two branches using subsearches to determine the most popular hosts and sources.| from main | branch [stats count() BY host | where count > 50 select host | into p_hosts], [stats count() BY source | where count > 100 select source | into p_sources]
dedupRemoves the events that contain an identical combination of values for the fields that you specify.Example: Remove duplicates of results with the same host value.... | dedup host
evalCalculates an expression and puts the resulting value into a search results field.Example: Create a new field that contains the result of a calculation. Create a new field called velocity in each event. Calculate the velocity by dividing the values in the distance field by the values in the time field.... | eval velocity=distance/time
Example: Use the if function to analyze field values. Create a new field called error in each event. Using the if function, set the value in the error field to OK if the status value is 200. Otherwise set the error field value to Problem.... | eval error = if(status == 200, "OK", "Problem")
eventstatsGenerates summary statistics from fields in your events and saves those statistics into a new field.Example: Calculate an average for each distinct value of the date_minute field. The new field avgdur is added to each event with the average value based on its particular value of date_minute.... | eventstats avg(duration) AS avgdur BY date_minute
expandProduce a separate result row for each object in an array that is in a field.Example: Expand the array in the bridges field. Here is the event before the field is expanded:_timebridges5 May 2021 2:29:02 PM[{“name”:”Tower Bridge”,”length”:801},{“name”:”Millennium Bridge”,”length”:1066}]... | expand bridgesHere are the results after the expand command is run:_timebridges5 May 2021 2:29:02 PM{“name”:”Tower Bridge”,”length”:801}5 May 2021 2:29:02 PM{“name”:”Millennium Bridge”,”length”:1066}
fieldsKeeps or removes fields from search results based on the list of fields that you specify.Example: Specify a list of fields to include in the search results. Return only the host and src fields from the search results.... | fields host, src
fieldsummaryCalculates summary statistics for one or more fields in your events, displayed as a results table.Example: Return the summary statistics for all incoming fields....| fieldsummary
Example: Return the summary statistics for a specific field....| fieldsummary fields=[action]
flattenConverts the key-value pairs in the object into separate fields in an event. Flattens only the first level of an object.Example: Flattens the values in the bridges object into separate fields.| FROM [{}] SELECT _time, {name: "Tower Bridge", length: 801} as bridges | flatten bridgesThe results look like this:_timebridgeslengthname21 Sep 2022 2:34:17 PM[{“name”:”Tower Bridge”, “length”:801}]801Tower Bridge
fromRetrieves data from a dataset, such as an index, metric index, lookup, view, or job.The from command has a flexible syntax, which enables you to start a search with either the FROM clause or the SELECT clause.Example: Return data from the main index for the last 5 minutes. Group the results by host. Calculate the sum of the bytes field. Return the sum and the host fields where the sum of the bytes is greater than I MB.| FROM main WHERE earliest=-5m@m AND latest=@m GROUP BY host SELECT sum(bytes) AS sum, host HAVING sum > 1024*1024
headReturns the first N number of specified results in search order.Example: Stop searching when a null value is encountered. This example returns results while action=purchase or the action field does not exist in the results (null=true). A maximum of 50 results are returned....| head while (action="purchase") null=true 50
intoSends results to a dataset that is writable, a dataset sink. Appends or replaces the dataset sink in the search data pipeline.Example: Append the search results to the mytable dataset, which is a lookup kind of dataset.... | into mode=append mytable
joinCombines the results from two datasets by using one or more common fields.Example: Join datasets on fields that have the same name. Combine the results from a search with the vendors dataset. The data is joined on the product_id field, which is common to both datasets.... | join left=L right=R where L.product_id=R.product_id vendors
lookupInvokes field value lookups.Example: Put corresponding information from a lookup dataset into your events.Append the data returned from your search results with the data in the users lookup dataset using the uid field. For search results that contains a uid field, the value in that field is matched with the uid field in the users lookup dataset. The username and department fields from the users lookup dataset are appended to each search result. If the search results already have the username and department fields, the OUTPUTNEW argument only fills in missing values in those fields.... | lookup users uid OUTPUTNEW username, department
mvexpandExpands the values of a multivalue field into separate events, one event for each value in the multivalue field.Example: Expand the values in the myfield field.... | mvexpand myfield
renameRenames one or more fields.Example: Rename a field with special characters. Rename the ip-add field to IPAddress. Field names that contain anything other than a-z, A-Z, 0-9, or “_”, need single-quotation marks.... | rename 'ip-add' AS IPAddress
reverseReverses the order of the search results.Example:... | reverse
rexUse to either extract fields using regular expression named groups, or replace or substitute characters in a field using sed expressions.Example: Extract values from a field using a <regex-expression>. Extract userapp, and SavedSearchName from a field called savedsearch_id in scheduler.log events.... | rex field=savedsearch_id "(?<user>\\w+);(?<app>\\w+);(?<SavedSearchName>\\w+)"If the contents of the field is savedsearch_id=bob;search;my_saved_search then this rex command syntax extracts user=bobapp=search, and SavedSearchName=my_saved_search.
searchRetrieve events from indexes or filter the results of a previous search command in the pipeline.Example: Search for a field-value pair for a specific source IP, src.search src="192.0.2.0"
Example: Search for multiple field-value pairs with boolean and comparison operators. This example searches for events with code values of either 10, 29, or 43 and any host that is not “localhost”, and an xqp value that is greater than 5.search (code=10 OR code=29 OR code=43) host!="localhost" xqp>5
selectSee the from command. The SELECT clause is part of the from command.Example: Calculate the sum of the bytes field. Return the sum and the host fields from the main index for the last 5 minutes. Group the results by host.| SELECT sum(bytes) AS sum, host FROM main WHERE earliest=-5m@m GROUP BY host
sortSorts all of the results by the specified fields.Example: Sort the results first by the surname field in ascending order and then by the firstname field in descending order.... | sort surname, -firstname
spl1Embed all or part of an SPL search into an SPL2 search. The spl1 command supports two syntaxes: backtick ( ` ) character syntax and explicit spl1 command syntax.Example: Consider this SPL search:error OR http_code=404Embed this search into an SPL2 search using the backtick ( ` ) character syntax:`search index=main error OR http_code=404`
Example: In this SPL2 search only the portion of the search not supported by SPL2, the addinfo command, uses the backtick ( ` ) character syntax:from sample_data_index | stats sum(bytes) BY host | `addinfo`
statsCalculates aggregate statistics such as average, count, and sum, over the results set.Example: Take the incoming result set and calculate the sum of the bytes field and groups the sums by the values in the host field.... | stats sum(bytes) BY host
streamstatsAdds a cumulative statistical value to each search result as each result is processed.Example: Use a <by-clause> to add a running count to search results. This search uses the host field to reset the count. For each search result, a new field is appended with a count of the results based on the host value. The count is cumulative and includes the current result.... | streamstats count() BY host
thruWrites data to a writeable dataset and then passes the same data to the next command in the search string. By default, the thru command appends data to the dataset.Example: Append all the incoming search result set to the actions dataset. Those same search results are also passed into the eval command.... | thru actions | eval field=<expr>
timechartCreates a time series chart with corresponding table of statistics.Example: For each minute, calculate the average value of the CPU field for each host.... | timechart span=1m avg(CPU) BY host
timewrapCompare data over a specific time period, such as day-over-day or month-over-month, or multiple time periods, such as a two week period over another two week period.Example: Display a timechart that has a span of 1 day for each count in a week over week comparison table. Each table column, which is the series, is 1 week of time.... | timechart count span=1d | timewrap 1week
unionMerges the results from two or more datasets into one dataset. One dataset can be piped into the union command and merged with a second dataset.Example: Merge events from the customers, orders, and vendors datasets. You must separate the dataset names with a comma.| union customers, orders, vendors
Example: Append the current results of the main search with the tabular results of errors from the subsearch.... | stats count() BY category1 | union [search error | stats count() BY category2]
whereFilters search results based on the outcome of a Boolean expression.Example: Use the like comparison operator with the percent symbol ( % ) as a wildcard. This example returns all results where the ipaddress field contains values that start with “192.”.... | where ipaddress like "192.%"
Example: Compare one field to another field.... | where ipaddress=clientip
Example: Filter using a field-value pair.... | where host="www1"
Rajesh Kumar
Follow me
Latest posts by Rajesh Kumar (see all)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x