A transaction is any group of conceptually-related events that spans time, such as a series of events related to the online reservation of a hotel room by a single customer, or a set of events related to a firewall intrusion incident. A transaction type is a configured transaction, saved as a field and used in conjunction with the
transaction command. Any number of data sources can generate transactions over multiple log entries.
A transaction search is useful for a single observation of any physical event stretching over multiple logged events. Use the transaction command to define a transaction or override transaction options specified in
A common transaction search use is to group multiple events into a single meta-event that represents a single physical event. For example, an out of memory problem could trigger several database events to be logged, and they can all be grouped together into a transaction.
To learn more, read "Identify and group events into transactions" in this manual.
When to use stats instead of transactions
stats command is meant to calculate statistics on events grouped by one or more fields and discard the events (unless you are using eventstats or streamstats). On the other hand, except for the duration between first and last events and the count of events, the
transaction command does not compute statistics over the grouped events. Additionally, it retains the raw event and other field values from the original event and enables you to group events using much more complex criteria, such as limiting the grouping by time span or delays and requiring terms to define the start or end of a group.
transaction command is most useful in two specific cases:
1. When a unique ID (from one or more fields) alone is not sufficient to discriminate between two transactions. This is the case when the identifier is reused, for example web sessions identified by cookie or client IP. In this case, time spans or pauses are also used to segment the data into transactions. In other cases, when an identifier is reused, for example in DHCP logs, a particular message may identify the beginning or end of a transaction.
2. When it is desirable to see the raw text of the events combined rather than an analysis on the constituent fields of the events.
In other cases, it's usually better to use the
stats command, which performs more efficiently, especially in a distributed environment. Often there is a unique ID in the events and
stats can be used.
For example, to compute the statistics on the duration of trades identified by the unique ID
trade_id, the following searches will yield the same answer:
... | transaction trade_id | chart count by duration span=log2
... | stats range(_time) as duration by trade_id | chart count by duration span=log2
If however, the
trade_id values are reused but each trade ends with some text, such as "END", the only solution is to use this
... | transaction trade_id endswith=END | chart count by duration span=log2
On the other hand, if
trade_id values are reused, but not within a 10 minute duration, the solution is to use the following
... | transaction trade_id maxpause=10m | chart count by duration span=log2
Read more about "About event grouping and correlation" in an earlier chapter in this manual.
Transactions and macro search
Transactions and macro searches are a powerful combination that allow substitution into your transaction searches. Make a transaction search and then save it with
$field$ to allow substitution.
For an example of how to use macro searches and transactions, see "Create and use search macros" in the this manual.
Use time to identify relationships between events
Identify and group events into transactions
This documentation applies to the following versions of Splunk® Enterprise: 5.0, 5.0.1, 5.0.2, 5.0.3, 5.0.4, 5.0.5, 5.0.6, 5.0.7, 5.0.8, 5.0.9, 5.0.10, 5.0.11, 5.0.12, 5.0.13, 5.0.14, 5.0.15, 5.0.16, 5.0.17, 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.0.7, 6.0.8, 6.0.9, 6.0.10, 6.0.11, 6.0.12, 6.0.13, 6.1, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.5, 6.1.6, 6.1.7, 6.1.8, 6.1.9, 6.1.10, 6.1.11, 6.1.12