Transactions enable you to search, and report on transactions in your data indexed in Splunk. A transaction is a grouping of events that contain related pieces of information. Transaction search is useful for a single observation of any physical event stretching over multiple logged events.
Here is an example of what can make up a transaction:
In this case, the Web access log might share a session ID with the event in the application server log; the application server log might contain the account ID, transaction ID, and product ID; the transaction ID may live in the message queue with a message ID, and the fulfillment application may log the message ID along with the shipping status. All of this data represents a single user transaction.
Example use casesThere are many cases where a transaction search may be useful. Here are some use cases for transaction search:
Search for transactions using the transaction search command. transaction yields groupings of events which may then be used in reports. To use transaction, either call a pre-configured transaction type, or define (or override) transaction constraints during your search via transaction command options.
Example transaction searchesRun a search that groups together all of the pages a single user (or client IP address) looked at over a time range.
This 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).
Transactions and macro search are a powerful combination that allow substitution into your transaction searches. Make a transaction search and then save it with $field$ to allow substitution.
When to not use transactionsTransactions aren't the most efficient method to compute aggregate statistics on transactional data. If you want to compute aggregate statistics over transactions that are defined by data in a single field, use the stats command.
For example, to compute the statistics of the duration of a transaction defined by the field trade_id:
* | stats min(_time) as earliest max(_time) as latest by trade_id | eval duration = latest-earliest | stats min(duration) max(duration) avg(duration) median(duration) perc95(duration)Similarly, if you want to compute the number of hits per clientip in an access log:
Also, compute the number of distinct sessions (parameterized by cookie) per clientip in an access log:
Comments
The "When to not use transactions" section is somewhat misleading in the post 3.3 world. Transaction searches have become 6x faster and are just as fast as 'stats' and often faster. For simple stats there's no reason to not use stats, but if you really want grouped transactions of events, use the transaction command
Posted by carasso on Aug 11 2008, 12:50am
What is the syntax for subseting multiple fields?
Posted by lital on Apr 13 2008, 2:15am