1.Transaction概念
Transaction是一个事件组,其中内容是在一定时间范围内一组概念关联的事件。比如:
- 一组session ID相同的web访问事件
- 一组具有相同message ID的消息队列事件
- 一组具有相同订单号的购物车事件
- ……
2.transaction
命令
我们可以使用transaction
命令来查找、收集我们关注的transaction。使用该命令时,可将事件的关联关系视为“条件约束”,transaction
命令将基于约束条件来搜寻所有被满足的事件分组,并以“分组”为基本单位来展开分析视图。那么“分组”结果中具体都会呈现哪些信息呢?具体如下:
- 每个事件的原始文本内容
- 最早事件的时间戳信息
- 每个事件的所有字段(除了时间戳)的合集
- <新增>
duration
,表示该组事件的持续时间 - <新增>
eventcount
,表示该组事件的元素数量
2.1 transaction
语法
transaction [<field-list>] [name=<transaction-name>] [<txn_definition-options>...] [<memcontrol-options>...] [<rendering-options>...]
可选参数:
- field-list
- 语法:<field>
- 描述:一个或者多个字段名称。限定事件的分组条件,只有当这些字段的值相等的情况下,才会被归为一组。
- memecontrol-options
- 语法:<maxopentxn> | <maxopenevents> | <keepevicted>
- 描述:对命令执行过程中内存使用的情况进行控制。
- name
- 语法:name=<transaction-name>
- 描述:transaction检索的定义可以写在
transactiontypes.conf
中,作为一种transaction type,那么这里就可以name
参数的方法来直接引用config文件中已存在的定义了。如果检索时给出了transaction
命令的其他参数,那么将会以检索时给出的参数覆盖掉预定义参数。
- rendering-options
- 语法: <delim> | <mvlist> | <mvraw> | <nullstr>
- 描述: These options control the multivalue rendering for your transactions. They are not required, but you can use 0 or more of the options to define your transaction.
- txn_definition-options
- 语法:<maxspan> | <maxpause> | <maxevents> | <startswith> | <endswith> | <connected> | <unifyends> | <keeporphans>
- 描述:关于transaction更细致的定义,参见以下详情。
- connected
- 语法: connected=<bool>
- 描述: 该参数定义了一种分组处理方式,比如事件序列
e1:{f1=a},e2:{f1=a},e3:{f1=a},e4:{f1=a,f2=b}
。那么当使用transaction f1 f2
时,前三个事件先形成了一个分组,对于第四个事件e4
,由于f1
字段与前期建立的分组一致,但是有所区别的是首次出现了f2
字段,那么这种情况下,e4
事件是与前三个事件同属一个分组呢还是另属于一个新的分组呢?connected=t
将会使得新开一个分组,而connected=f
则反之。
- endswith
- 语法:endswith=<string>
- 描述:如果一个事件满足,则标记着transaction结束。
- keeporphans
- 语法:keeporphans=true | false
- 描述:规定
transaction
命令是否输出不属于任何一个事务的的事件结果。如果输出这样的事件,那么这些事件将区别于transaction事件,均会标识有一个_txn_orphan
字段(=1)。
- maxspan
- 语法:maxspan=<int>[s | m | h | d]
- 描述:限定transaction时间跨度范围(首个事件与末尾事件的时间差),可以秒、分、时或者天为单位。如果设置为负值,则认为不设上限。
- maxpause
- 语法:maxpause=<int>[s | m | h | d]
- 描述:限定transaction内,任意相邻两事件之间的时间差上限,可以秒、分、时或者天为单位。如果设置为负值,则认为不设上限。
- maxevents
- 语法:maxevents=<int>
- 描述:限定transaction内事件数量上限。如果设置为负值,则认为不设上限。
- startswith
- 语法:startswith=<filter-string>
- 描述:如果一个事件满足,则标记着新的transaction开始。
- unifyends
- 语法:unifyends= true | false
- 描述:对于满足
startswith
与endswith
条件的时间,是否仍然强制其满足其它的事件关联条件。
- connected
- Memory constraint options
- keepevicted
- 语法:keepevicted=<bool>
- 描述:设定是否输出
evicted
状态下的 transactions. Evicted transactions can be distinguished from non-evicted transactions by checking the value of the 'closed_txn' field, which is set to '0' for evicted transactions and '1' for closed ones. 'closed_txn' is set to '1' if one of the following conditions is hit: maxevents, maxpause, maxspan, startswith (for this last one, because transaction sees events in reverse time order, it closes a transaction when it satisfies the start condition). If none of these conditions is specified, all transactions will be output even though all transactions will have 'closed_txn' set to '0'. A transaction can also be evicted when the memory limitations are reached.
- maxopenevents
- 语法:maxopenevents=<int>
- 描述:设定内存中维护的事件最大规模,使用LRU策略。The default value of this field is read from the transactions stanza in the .limits.conf file.
- maxopentxn
- 语法:maxopentxn=<int>
- 描述:设定内存中维护的transaction最大规模,使用LRU策略。The default value of this field is read from the transactions stanza in the limits.conf file.
- keepevicted
- Multivalue rendering options
- delim
- 语法:delim=<string>
- 描述:Specify a character to separate multiple values. When used in conjunction with mvraw=t, represents a string used to delimit the values of _raw.
- mvlist
- 语法:mvlist= true | false | <field-list>
- 描述:设定transaction对于其中事件字段值合并后的多值字段的表示方式,1)mvlist=t:按照事件出现顺序的相应值列表,2)mvlist=f:按照字母序的值集合。If a comma or/space delimited list of fields is provided, only those fields are rendered as lists.
- mvraw
- 语法:mvraw=<bool>
- 描述:Used to specify whether the _raw field of the transaction search result should be a multivalued field.
- nullstr
- 语法:nullstr=<string>
- 描述:A string value to use when rendering missing field values as part of multivalued fields in a transaction. This option applies only to fields that are rendered as lists.
- delim