Search modifiers are used in the search command, and allow you to modify the results of a search based on time constraints, and other factors. Modifiers are explicitly used within the context of the search command.
There are two types of search modifiers. Search modifiers allow you to specify criteria to narrow your search, and time modifiers that adjust start/stop times and time ranges of your search.
| Time modifiers = | daysago, enddaysago, endhoursago, endminutesago, endmonthsago, endtime, endtimeeu, hoursago, minutesago, monthsago, searchtimespandays, searchtimespanhours, searchtimespanminutes, searchtimespanmonths, startdaysago, starthoursago, startminutesago, startmonthsago, starttime, starttimeeu, timeformat |
| Search modifiers = | eventtypetag, hosttag, index, maxresults, readlevel, readlimit, related |
In versions 3.0.x modifiers take the format of:
In versions 3.1.x and above, modifiers take the formats:
Most modifiers do not have default values. Modifiers may appear anywhere in a Splunk command before, after, or in between keywords and logical expressions. If a search has conflicting modifiers, the first one from left to right will take precedence.
Search modifier precedencecommand argument ... [argument] ...
| argument=syntax and value(default value) | Description, and usage. |
./splunk search "foo | top"
Search events within the last N days.
Syntaxdaysago=integer
enddaysagoSet an end time (in days) that is = now - number specified.
Syntaxenddaysago=integer
endhoursagoSet an end time (in hours) that is = now - number specified.
Syntaxendhoursago=integer
endminutesagoSet an end time (in minutes) that is = now - number specified.
Syntaxendminutesago=integer
endmonthsagoSet an end time (in months) that is = now - number specified.
Syntaxendmonthsago=integer
endtimeAll events must be before the specified time. Use timeformat to set the time format to use. For example: if timeformat=%m/%d/%Y:%H:%M:%S, then endtime=09/07/1978:09:00:00, and all results are before that time.
Syntaxendtime=string
hosttagSearch for events that have hosts that have a matching host tag string.
Syntaxhosttag=string
hoursagoSearch events within the last N hours.
Syntaxhoursago=integer
indexSpecifies an index to search (main, default, history, splunklogger, or another admin defined index). If there is more than one index modifier in a search command argument, only the first declaration will be evaluated.
Syntaxindex="name of index" | name of index
maxresultsLimit the number of results that your search returns by specifying a maximum number of results. The default number of events for any search to return is 10,000.
Syntaxmaxresults=integer(10000)
minutesagoSearch events within the last N minutes.
Syntaxminutesago=integer
monthsagoSearch events within the last N months.
Syntaxmonthsago=integer
readlevelSpecifies how much detail is read from events returned from the search processor. This modifier is only useful in command line searches.
Syntaxreadlevel=level
Arguments| level= 0 | 1 | 2 | Different read levels to specify. |
| 0 | Specifies that only the top indexed fields (host,source, sourcetype) get read. |
| 1 | Specifies to read raw data and 2nd order fields in addition to top indexed fields (read level 0). |
| 2 | Specifies a full read of event types in addition to all of the above data. |
Specify the starting point of events within your results to read and return. By default this is set to 0 (to read all events).
Syntaxreadlimit=integer | "integer range"
Specifies events that are related to the event of id event_id. The value assigned to a related search is a hash value that only makes sense to the server. Related results are sorted by relevance rather than by time.
Syntaxrelated=hash value
Search for events that would be found by the specified saved search.
Syntaxsavedsearch=name_of_saved_search
searchtimespanminutesSearch within a specified range of minutes (expressed as an integer).
Syntaxsearchtimespanminutes=integer
searchtimespanhoursSearch within a specified range of hours (expressed as an integer).
Syntaxsearchtimespanhours=integer
searchtimespandaysSearch within a specified range of days (expressed as an integer).
Syntaxsearchtimespandays=integer
searchtimespanmonthsSearch within a specified range of months (expressed as an integer).
Syntaxsearchtimespanmonths=integer
startminutesagoSearch the specified number of minutes ago from the present time (expressed as an integer).
Syntaxminutesago=integer
starthoursagoSearch the specified number of hours ago from the present time (expressed as an integer).
Syntaxhoursago=integer
startdaysagoSearch the specified number of days ago from the present time (expressed as an integer).
Syntaxdaysago=integer
startmonthsagoSearch the specified number of months ago from the present time (expressed as an integer).
Syntaxmonthsago=integer
timeformatChange the format for the starttime and endtime modifiers. All Splunk searches have the default time format of: %m/%d/%Y:%H:%M:%S.
Syntaxtimeformat=string
Arguments| string = | %m/%d/%Y:%H:%M:%S (default = %m/%d/%Y:%H:%M:%S). |
Comments
Example:
sourcetype="syslog" warning daysago=1
Posted by mzigliotto on Jul 09 2008, 2:28pm
examples should include entire search queries so that people could get a feel for how to use these commands.
Posted by foster2 on Dec 14 2007, 5:34am