Analysis Commands
Commands that find unusual values, forecast trends, group similar messages and compare periods. They work on the current results, so they usually follow stats or timechart.
outlier
Caps or removes values far outside the usual range: above the third quartile plus param × the interquartile range (IQR), and, with uselower=true, below the first quartile minus that.
Syntax:
outlier [action=transform|remove] [param=<number>] [uselower=<bool>] [mark=<bool>] [<field> ...]| Option | Default | Description |
|---|---|---|
action= | transform | transform replaces an outlier with the limit; remove drops its row |
param= | 2.5 | How many IQRs beyond the quartiles a value must be |
uselower= | false | Also treat values far below the range as outliers |
mark= | false | With transform, prefix replaced values with 000 |
Without fields, every numeric column of the results is checked.
Example:
timechart span=5m avg(duration) as latency
| outlier action=remove latencyanomalydetection
Finds rows with an unusual value.
Syntax:
anomalydetection [method=histogram|zscore|iqr] [action=filter|annotate] [pthresh=<p>] [<field> ...]| Method | A value is unusual when |
|---|---|
histogram (default) | Fewer than pthresh of the rows share it. Numbers are first put into 10 equal ranges |
zscore | It is further from the mean than a share of pthresh of a normal distribution would be (2.58 standard deviations for the default 0.01) |
iqr | It is more than 1.5 × IQR beyond the quartiles |
action=filter(default) keeps only the unusual rows.action=annotatekeeps every row and addsisOutlier(1 or 0) and, forhistogram,log_event_prob.pthreshdefaults to 0.01.- Without fields, every column except
_timeis checked.
Examples:
stats count by workload, level
| anomalydetection leveltimechart span=10m count
| anomalydetection method=zscore action=annotate count
| where isOutlier = 1predict
Forecasts a timechart series: fits a straight-line trend and continues it into the future.
Syntax:
predict <field> [as <name>] ... [future_timespan=<N>] [holdback=<N>]- Adds
prediction(<field>)(or theasname) with a 95% band,upper95(prediction(<field>))andlower95(prediction(<field>)), from how far the values stray from the trend. future_timespan(default 5) adds that many future buckets, with the prediction and no actual value.holdbackleaves the last N buckets out of the fit, to see how well it predicts them.- It follows a
timechartwithoutby.
Example:
timechart span=1h count
| predict count future_timespan=24info: predict fits a straight line (Splunk's algorithm=LLT). Splunk's default algorithms also model seasonality; they, period=, correlate= and suppress= are not supported. For a daily pattern, compare periods with timewrap instead.
cluster
Groups similar messages: messages that differ only in numbers, IDs, UUIDs, IP addresses or quoted values belong together.
Syntax:
cluster [field=<field>] [showcount=<bool>] [countfield=<name>] [labelfield=<name>] [labelonly=<bool>]| Option | Default | Description |
|---|---|---|
field= | _raw | The field to group |
showcount= | false | Add each group's size |
countfield= | cluster_count | Name of the size column |
labelfield= | cluster_label | Name of the group number column |
labelonly= | false | Keep every row, with its group number, instead of one row per group |
Without labelonly, the result has one row per group (its newest message), largest group first. Groups are numbered from 1, largest first.
Examples:
level=error
| cluster showcount=true
| table cluster_count, bodylevel=error
| cluster labelonly=true
| stats count, values(pod_name) as pods by cluster_labelSplunk's similarity threshold, t=, is accepted and ignored. To count message templates over long time ranges, tstats count by pattern is faster.
timewrap
Lines up the periods of a timechart side by side, for comparing today with yesterday or this week with last week.
Syntax:
timewrap <period>The period is seconds to weeks: 1d, 1w, 12h. Each bucket moves onto the latest period, and its values go to that period's column: count_latest_day, count_1day_before, count_2days_before, … Periods are counted back from the end of the time range. A time range may hold at most 100 periods.
Example:
With a time range of the last 7 days:
timechart span=1h count
| timewrap 1dThis returns 24 rows, one per hour of the day, with a column for each of the seven days.