lttng-enable-event(1): filtering: specify that `$ctx.cpu_id` is available
[lttng-tools.git] / doc / man / lttng-enable-event.1.txt
CommitLineData
e9b06e2b
PP
1lttng-enable-event(1)
2=====================
3
4
5NAME
6----
7lttng-enable-event - Create or enable LTTng event rules
8
9
10SYNOPSIS
11--------
12Create or enable Linux kernel event rules:
13
14[verse]
ce19b9ed 15*lttng* ['linkgenoptions:(GENERAL OPTIONS)'] *enable-event* option:--kernel
e9b06e2b
PP
16 [option:--probe='SOURCE' | option:--function='SOURCE' | option:--syscall]
17 [option:--filter='EXPR'] [option:--session='SESSION']
18 [option:--channel='CHANNEL'] 'EVENT'[,'EVENT']...
19
20Create or enable an "all" Linux kernel event rule:
21
22[verse]
ce19b9ed 23*lttng* ['linkgenoptions:(GENERAL OPTIONS)'] *enable-event* option:--kernel option:--all [option:--syscall]
e9b06e2b
PP
24 [option:--filter='EXPR'] [option:--session='SESSION'] [option:--channel='CHANNEL']
25
26Create or enable application event rules:
27
28[verse]
ce19b9ed 29*lttng* ['linkgenoptions:(GENERAL OPTIONS)'] *enable-event*
e9b06e2b
PP
30 (option:--userspace | option:--jul | option:--log4j | option:--python)
31 [option:--filter='EXPR'] [option:--exclude='EVENT'[,'EVENT']...]
32 [option:--loglevel='LOGLEVEL' | option:--loglevel-only='LOGLEVEL']
33 [option:--session='SESSION'] [option:--channel='CHANNEL'] (option:--all | 'EVENT'[,'EVENT']...)
34
35
36DESCRIPTION
37-----------
38The `lttng enable-event` command can create a new event rule, or enable
39one or more existing and disabled ones.
40
41An event rule created by `lttng enable-event` is a set of conditions
42that must be satisfied in order for an actual event to be emitted by
43an LTTng tracer when the execution of an application or the Linux kernel
44reaches an event source (tracepoint, system call, dynamic probe).
7c1a4458 45Event sources can be listed with the man:lttng-list(1) command.
e9b06e2b 46
7c1a4458 47The man:lttng-disable-event(1) command can be used to disable
e9b06e2b
PP
48existing event rules.
49
50Event rules are always assigned to a channel when they are created. If
51the option:--channel option is omitted, a default channel named
52`channel0` is used (and created automatically if it does not exist for
53the specified domain in the selected tracing session).
54
55If the option:--session option is omitted, the chosen channel is picked
56from the current tracing session.
57
58Events can be enabled while tracing is active
7c1a4458 59(use man:lttng-start(1) to make a tracing session active).
e9b06e2b
PP
60
61
62Event source types
63~~~~~~~~~~~~~~~~~~
64Four types of event sources are available in the Linux kernel tracing
65domain (option:--kernel option):
66
67Tracepoint (option:--tracepoint option; default)::
68 A Linux kernel tracepoint, that is, a static instrumentation point
69 placed in the kernel source code. Standard tracepoints are designed
70 and placed in the source code by developers and record useful
71 payload fields.
72
73Dynamic probe (option:--probe option)::
74 A Linux kernel kprobe, that is, an instrumentation point placed
75 dynamically in the compiled kernel code. Dynamic probe events do not
76 record any payload field.
77
78Function probe (option:--function option)::
79 A Linux kernel kretprobe, that is, two instrumentation points placed
80 dynamically where a function is entered and where it returns in the
81 compiled kernel code. Function probe events do not record any
82 payload field.
83
84System call (option:--syscall option)::
85 A Linux kernel system call. Two instrumentation points are
86 statically placed where a system call function is entered and where
87 it returns in the compiled kernel code. System call event sources
88 record useful payload fields.
89
90The application tracing domains (option:--userspace, option:--jul,
91option:--log4j, or option:--python options) only support tracepoints.
92In the cases of the JUL, Apache log4j, and Python domains, the event
93names correspond to _logger_ names.
94
95
96Understanding event rule conditions
97~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98When creating an event rule with `lttng enable-event`, conditions are
99specified using options. The logical conjunction (logical AND) of all
100those conditions must be true when an event source is reached by an
101application or by the Linux kernel in order for an actual event
102to be emitted by an LTTng tracer.
103
104Any condition that is not explicitly specified on creation is considered
105a _don't care_.
106
107For example, consider the following commands:
108
d4f093aa 109[role="term"]
e9b06e2b
PP
110----------------------------------------------------------------
111lttng enable-event --userspace hello:world
112lttng enable-event --userspace hello:world --loglevel=TRACE_INFO
113----------------------------------------------------------------
114
115Here, two event rules are created. The first one has a single condition:
116the tracepoint name must match `hello:world`. The second one has two
117conditions:
118
119* The tracepoint name must match `hello:world`, _and_
120* The tracepoint's defined log level must be at least as severe as
121 the `TRACE_INFO` level.
122
123In this case, the second event rule is pointless because the first one
124is more general: it does not care about the tracepoint's log level.
125If an event source matching both event rules is reached by the
126application's execution, only one event is emitted.
127
128The available conditions for the Linux kernel domain are:
129
130* Tracepoint/system call name ('EVENT' argument with
131 option:--tracepoint or option:--syscall options) or
132 dynamic probe/function name/address
133 (option:--probe or option:--function option's argument) which must
134 match event source's equivalent.
135+
136Wildcard using the `*` character are supported _at the end_ of
137tracepoint and system call names.
138
139* Filter expression (option:--filter option) executed against the
140 dynamic values of event fields at execution time that must evaluate
141 to true. See the <<filter-syntax,Filter expression syntax>> section
142 below for more information.
143
144The available conditions for the application domains are:
145
146* Tracepoint name ('EVENT' with option:--tracepoint option) which must
147 match event source's equivalent.
148+
149Wildcard using the `*` character are supported _at the end_ of
150tracepoint names. When creating an event rule with a tracepoint name
151containing a wildcard, specific tracepoint names can be excluded from
152the match using the option:--exclude option.
153
154* Filter expression (option:--filter option) executed against the
155 dynamic values of event fields at execution time that must evaluate
156 to true. See the <<filter-syntax,Filter expression syntax>> section
157 below for more information.
158* Event's log level that must be at least as severe as a given
159 log level (option:--loglevel option) or match exactly a given log
160 level (option:--loglevel-only option).
161
162When using `lttng enable-event` with a set of conditions that does not
163currently exist for the chosen tracing session, domain, and channel,
164a new event rule is created. Otherwise, the existing event rule is
165enabled if it is currently disabled
7c1a4458 166(see man:lttng-disable-event(1)).
e9b06e2b
PP
167
168The option:--all option can be used alongside the option:--tracepoint
169or option:--syscall options. When this option is used, no 'EVENT'
170argument must be specified. This option defines a single event rule
171matching _all_ the possible events of a given tracing domain for the
172chosen channel and tracing session. It is the equivalent of an 'EVENT'
173argument named `*` (wildcard).
174
175
176[[filter-syntax]]
177Filter expression syntax
178~~~~~~~~~~~~~~~~~~~~~~~~
1e85dcc6
PP
179A filter expression can be specified with the option:--filter option
180when creating a new event rule. If the filter expression evaluates to
181true when executed against the dynamic values of an event's fields when
182tracing, the filtering condition passes.
e9b06e2b 183
60f7980c
PP
184NOTE: Make sure to **single-quote** the filter expression when running
185the command from a shell, as filter expressions typically include
186characters having a special meaning for most shells.
187
e9b06e2b
PP
188The filter expression syntax is very similar to C language conditional
189expressions (expressions that can be evaluated by an `if` statement).
190
191The following logical operators are supported:
192
193[width="40%",options="header"]
194|=====================================
195| Name | Syntax
196| Logical negation (NOT) | `!a`
197| Logical conjunction (AND) | `a && b`
198| Logical disjunction (OR) | `a \|\| b`
199|=====================================
200
201The following comparison operators/relational operators are supported:
202
203[width="40%",options="header"]
204|====================================
205| Name | Syntax
206| Equal to | `a == b`
207| Not equal to | `a != b`
208| Greater than | `a > b`
209| Less than | `a < b`
210| Greater than or equal to | `a >= b`
211| Less than or equal to | `a <= b`
212|====================================
213
214The arithmetic and bitwise operators are :not: supported.
215
216The precedence table of the operators above is the same as the one of
217the C language. Parentheses are supported to bypass this.
218
1e85dcc6
PP
219The dynamic value of an event field is read by using its name as a C
220identifier.
e9b06e2b
PP
221
222The dynamic value of a statically-known context field is read by
223prefixing its name with `$ctx.`. Statically-known context fields are
224context fields added to channels without the `$app.` prefix using the
1e85dcc6
PP
225man:lttng-add-context(1) command. `$ctx.cpu_id` is also available as the
226ID of the CPU which emits the event.
e9b06e2b
PP
227
228The dynamic value of an application-specific context field is read by
229prefixing its name with `$app.` (follows the format used to add such a
7c1a4458 230context field with the man:lttng-add-context(1) command).
e9b06e2b
PP
231
232When a comparison includes a non existent event field, the whole filter
233expression evaluates to false (the event is discarded).
234
235C integer and floating point number constants are supported, as well as
236literal strings between double quotes (`"`). Literal strings can contain
237a wildcard character (`*`) at the end to match more than one string.
bca82bfe 238This wildcard can be escaped using :escwc:.
e9b06e2b
PP
239
240LTTng-UST enumeration fields can be compared to integer values (fields
241or constants).
242
243NOTE: Although it is possible to filter the process ID of an event when
244the `pid` context has been added to its channel using, for example,
245`$ctx.pid == 2832`, it is recommended to use the PID tracker instead,
7c1a4458 246which is much more efficient (see man:lttng-track(1)).
e9b06e2b
PP
247
248Examples:
249
250----------------------------
251msg_id == 23 && size >= 2048
252----------------------------
253
254-------------------------------------------------
255$ctx.procname == "lttng*" && (!flag || poel < 34)
256-------------------------------------------------
257
258---------------------------------------------------------
259$app.my_provider:my_context == 17.34e9 || some_enum >= 14
260---------------------------------------------------------
261
262
263[[log-levels]]
264Log levels
265~~~~~~~~~~
266Tracepoints and log statements in applications have an attached log
267level. Application event rules can contain a _log level_ condition.
268
269With the option:--loglevel option, the event source's log level must
270be at least as severe as the option's argument. With the
271option:--loglevel-only option, the event source's log level must match
272the option's argument.
273
274The available log levels are:
275
276User space domain (option:--userspace option)::
277 Shortcuts such as `system` are allowed.
278+
279* `TRACE_EMERG` (0)
280* `TRACE_ALERT` (1)
281* `TRACE_CRIT` (2)
282* `TRACE_ERR` (3)
283* `TRACE_WARNING` (4)
284* `TRACE_NOTICE` (5)
285* `TRACE_INFO` (6)
286* `TRACE_DEBUG_SYSTEM` (7)
287* `TRACE_DEBUG_PROGRAM` (8)
288* `TRACE_DEBUG_PROCESS` (9)
289* `TRACE_DEBUG_MODULE` (10)
290* `TRACE_DEBUG_UNIT` (11)
291* `TRACE_DEBUG_FUNCTION` (12)
292* `TRACE_DEBUG_LINE` (13)
293* `TRACE_DEBUG` (14)
294
295`java.util.logging` domain (option:--jul option)::
296 Shortcuts such as `severe` are allowed.
297+
298* `JUL_OFF` (`INT32_MAX`)
299* `JUL_SEVERE` (1000)
300* `JUL_WARNING` (900)
301* `JUL_INFO` (800)
302* `JUL_CONFIG` (700)
303* `JUL_FINE` (500)
304* `JUL_FINER` (400)
305* `JUL_FINEST` (300)
306* `JUL_ALL` (`INT32_MIN`)
307
308Apache log4j domain (option:--log4j option)::
309 Shortcuts such as `severe` are allowed.
310+
311* `LOG4J_OFF` (`INT32_MAX`)
312* `LOG4J_FATAL` (50000)
313* `LOG4J_ERROR` (40000)
314* `LOG4J_WARN` (30000)
315* `LOG4J_INFO` (20000)
316* `LOG4J_DEBUG` (10000)
317* `LOG4J_TRACE` (5000)
318* `LOG4J_ALL` (`INT32_MIN`)
319
320Python domain (option:--python option)::
321 Shortcuts such as `critical` are allowed.
322+
323* `PYTHON_CRITICAL` (50)
324* `PYTHON_ERROR` (40)
325* `PYTHON_WARNING` (30)
326* `PYTHON_INFO` (20)
327* `PYTHON_DEBUG` (10)
328* `PYTHON_NOTSET` (0)
329
330
331include::common-cmd-options-head.txt[]
332
333
334Domain
335~~~~~~
336One of:
337
338option:-j, option:--jul::
339 Create or enable event rules in the `java.util.logging`
340 (JUL) domain.
341
342option:-k, option:--kernel::
343 Create or enable event rules in the Linux kernel domain.
344
345option:-l, option:--log4j::
346 Create or enable event rules in the Apache log4j domain.
347
348option:-p, option:--python::
349 Create or enable event rules in the Python domain.
350
351option:-u, option:--userspace::
352 Create or enable event rules in the user space domain.
353
354
355Target
356~~~~~~
28f32bdf 357option:-c 'CHANNEL', option:--channel='CHANNEL'::
e9b06e2b
PP
358 Create or enable event rules in the channel named 'CHANNEL' instead
359 of the default channel name `channel0`.
360
28f32bdf 361option:-s 'SESSION', option:--session='SESSION'::
e9b06e2b
PP
362 Create or enable event rules in the tracing session named 'SESSION'
363 instead of the current tracing session.
364
365
366Event source type
367~~~~~~~~~~~~~~~~~
368One of:
369
370option:--function='SOURCE'::
371 Linux kernel kretprobe. Only available with the option:--kernel
372 domain option. 'SOURCE' is one of:
373+
374* Function address (`0x` prefix supported)
375* Function symbol
376* Function symbol and offset (`SYMBOL+OFFSET` format)
377
378option:--probe='SOURCE'::
379 Linux kernel kprobe. Only available with the option:--kernel
380 domain option. 'SOURCE' is one of:
381+
382* Address (`0x` prefix supported)
383* Symbol
384* Symbol and offset (`SYMBOL+OFFSET` format)
385
386option:--syscall::
387 Linux kernel system call. Only available with the option:--kernel
388 domain option.
389
390option:--tracepoint::
391 Linux kernel or application tracepoint (default).
392
393
394Log level
395~~~~~~~~~
396One of:
397
398option:--loglevel='LOGLEVEL'::
399 Add log level condition to the event rule: the event source's
400 defined log level must be at least as severe as 'LOGLEVEL'.
401 See the <<log-levels,Log levels>> section above for the available
402 log levels. Only available with application domains.
403
404option:--loglevel-only='LOGLEVEL'::
405 Add log level condition to the event rule: the event source's
406 defined log level must match 'LOGLEVEL'. See the
407 <<log-levels,Log levels>> section above for the available log
408 levels. Only available with application domains.
409
410
411Filtering and exclusion
412~~~~~~~~~~~~~~~~~~~~~~~
28f32bdf 413option:-x 'EVENT'[,'EVENT']..., option:--exclude='EVENT'[,'EVENT']...::
e9b06e2b
PP
414 Exclude events named 'EVENT' from the event rule. This option
415 can be used when the command's 'EVENT' argument contains a wildcard
416 (`*`) to exclude specific names. Only available with application
417 domains.
418
28f32bdf 419option:-f 'EXPR', option:--filter='EXPR'::
e9b06e2b
PP
420 Add filter expression condition to the event rule. Expression 'EXPR'
421 must evaluate to true when executed against the dynamic values of
422 event fields. See the <<filter-syntax,Filter expression syntax>>
423 section above for more information.
424
425
426Shortcuts
427~~~~~~~~~
428option:-a, option:--all::
429 Equivalent to an 'EVENT' argument named `*` (wildcard) when also
430 using the option:--tracepoint (default) or option:--syscall option.
431
432
433include::common-cmd-help-options.txt[]
434
435
436include::common-cmd-footer.txt[]
437
438
439SEE ALSO
440--------
7c1a4458
PP
441man:lttng-disable-event(1),
442man:lttng(1)
This page took 0.041031 seconds and 4 git commands to generate.