]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/systemd.journal-fields.xml
Merge pull request #10134 from keszybz/test-runner
[thirdparty/systemd.git] / man / systemd.journal-fields.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5 <!--
6 SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="systemd.journal-fields">
10
11 <refentryinfo>
12 <title>systemd.journal-fields</title>
13 <productname>systemd</productname>
14 </refentryinfo>
15
16 <refmeta>
17 <refentrytitle>systemd.journal-fields</refentrytitle>
18 <manvolnum>7</manvolnum>
19 </refmeta>
20
21 <refnamediv>
22 <refname>systemd.journal-fields</refname>
23 <refpurpose>Special journal fields</refpurpose>
24 </refnamediv>
25
26 <refsect1>
27 <title>Description</title>
28
29 <para>Entries in the journal resemble an environment block in
30 their syntax but with fields that can include binary data.
31 Primarily, fields are formatted UTF-8 text strings, and binary
32 formatting is used only where formatting as UTF-8 text strings
33 makes little sense. New fields may freely be defined by
34 applications, but a few fields have special meaning. All fields
35 with special meanings are optional. In some cases, fields may
36 appear more than once per entry.</para>
37 </refsect1>
38
39 <refsect1>
40 <title>User Journal Fields</title>
41
42 <para>User fields are fields that are directly passed from clients
43 and stored in the journal.</para>
44
45 <variablelist class='journal-directives'>
46 <varlistentry>
47 <term><varname>MESSAGE=</varname></term>
48 <listitem>
49 <para>The human-readable message string for this entry. This
50 is supposed to be the primary text shown to the user. It is
51 usually not translated (but might be in some cases), and is
52 not supposed to be parsed for metadata.</para>
53 </listitem>
54 </varlistentry>
55
56 <varlistentry>
57 <term><varname>MESSAGE_ID=</varname></term>
58 <listitem>
59 <para>A 128-bit message identifier ID for recognizing certain message types, if this is desirable. This
60 should contain a 128-bit ID formatted as a lower-case hexadecimal string, without any separating dashes or
61 suchlike. This is recommended to be a UUID-compatible ID, but this is not enforced, and formatted
62 differently. Developers can generate a new ID for this purpose with <command>systemd-id128 new</command>.
63 </para>
64 </listitem>
65 </varlistentry>
66
67 <varlistentry>
68 <term><varname>PRIORITY=</varname></term>
69 <listitem>
70 <para>A priority value between 0 (<literal>emerg</literal>)
71 and 7 (<literal>debug</literal>) formatted as a decimal
72 string. This field is compatible with syslog's priority
73 concept.</para>
74 </listitem>
75 </varlistentry>
76
77 <varlistentry>
78 <term><varname>CODE_FILE=</varname></term>
79 <term><varname>CODE_LINE=</varname></term>
80 <term><varname>CODE_FUNC=</varname></term>
81 <listitem>
82 <para>The code location generating this message, if known.
83 Contains the source filename, the line number and the
84 function name.</para>
85 </listitem>
86 </varlistentry>
87
88 <varlistentry>
89 <term><varname>ERRNO=</varname></term>
90 <listitem>
91 <para>The low-level Unix error number causing this entry, if
92 any. Contains the numeric value of
93 <citerefentry project='man-pages'><refentrytitle>errno</refentrytitle><manvolnum>3</manvolnum></citerefentry>
94 formatted as a decimal string.</para>
95 </listitem>
96 </varlistentry>
97
98 <varlistentry>
99 <term><varname>SYSLOG_FACILITY=</varname></term>
100 <term><varname>SYSLOG_IDENTIFIER=</varname></term>
101 <term><varname>SYSLOG_PID=</varname></term>
102 <term><varname>SYSLOG_TIMESTAMP=</varname></term>
103 <listitem>
104 <para>Syslog compatibility fields containing the facility (formatted as
105 decimal string), the identifier string (i.e. "tag"), the client PID, and
106 the timestamp as specified in the original datagram. (Note that the tag is
107 usually derived from glibc's
108 <varname>program_invocation_short_name</varname> variable, see
109 <citerefentry project='die-net'><refentrytitle>program_invocation_short_name</refentrytitle><manvolnum>3</manvolnum></citerefentry>.)</para>
110 </listitem>
111 </varlistentry>
112
113 <varlistentry>
114 <term><varname>SYSLOG_RAW=</varname></term>
115 <listitem>
116 <para>The original contents of the syslog line as received in the syslog
117 datagram. This field is only included if the <varname>MESSAGE=</varname>
118 field was modified compared to the original payload or the timestamp could
119 not be located properly and is not included in
120 <varname>SYSLOG_TIMESTAMP=</varname>. Message truncation occurs when when
121 the message contains leading or trailing whitespace (trailing and leading
122 whitespace is stripped), or it contains an embedded
123 <constant>NUL</constant> byte (the <constant>NUL</constant> byte and
124 anything after it is not included). Thus, the original syslog line is
125 either stored as <varname>SYSLOG_RAW=</varname> or it can be recreated
126 based on the stored priority and facility, timestamp, identifier, and the
127 message payload in <varname>MESSAGE=</varname>.
128 </para>
129 </listitem>
130 </varlistentry>
131 </variablelist>
132 </refsect1>
133
134 <refsect1>
135 <title>Trusted Journal Fields</title>
136
137 <para>Fields prefixed with an underscore are trusted fields, i.e.
138 fields that are implicitly added by the journal and cannot be
139 altered by client code.</para>
140
141 <variablelist class='journal-directives'>
142 <varlistentry>
143 <term><varname>_PID=</varname></term>
144 <term><varname>_UID=</varname></term>
145 <term><varname>_GID=</varname></term>
146 <listitem>
147 <para>The process, user, and group ID of the process the
148 journal entry originates from formatted as a decimal
149 string. Note that entries obtained via <literal>stdout</literal> or
150 <literal>stderr</literal> of forked processes will contain credentials valid for a parent
151 process (that initiated the connection to <command>systemd-journald</command>).</para>
152 </listitem>
153 </varlistentry>
154
155 <varlistentry>
156 <term><varname>_COMM=</varname></term>
157 <term><varname>_EXE=</varname></term>
158 <term><varname>_CMDLINE=</varname></term>
159 <listitem>
160 <para>The name, the executable path, and the command line of
161 the process the journal entry originates from.</para>
162 </listitem>
163 </varlistentry>
164
165 <varlistentry>
166 <term><varname>_CAP_EFFECTIVE=</varname></term>
167 <listitem>
168 <para>The effective
169 <citerefentry project='man-pages'><refentrytitle>capabilities</refentrytitle><manvolnum>7</manvolnum></citerefentry>
170 of the process the journal entry originates from.</para>
171 </listitem>
172 </varlistentry>
173
174 <varlistentry>
175 <term><varname>_AUDIT_SESSION=</varname></term>
176 <term><varname>_AUDIT_LOGINUID=</varname></term>
177 <listitem>
178 <para>The session and login UID of the process the journal
179 entry originates from, as maintained by the kernel audit
180 subsystem.</para>
181 </listitem>
182 </varlistentry>
183
184 <varlistentry>
185 <term><varname>_SYSTEMD_CGROUP=</varname></term>
186 <term><varname>_SYSTEMD_SLICE=</varname></term>
187 <term><varname>_SYSTEMD_UNIT=</varname></term>
188 <term><varname>_SYSTEMD_USER_UNIT=</varname></term>
189 <term><varname>_SYSTEMD_SESSION=</varname></term>
190 <term><varname>_SYSTEMD_OWNER_UID=</varname></term>
191
192 <listitem>
193 <para>The control group path in the systemd hierarchy, the
194 the systemd slice unit name, the systemd unit name, the
195 unit name in the systemd user manager (if any), the systemd
196 session ID (if any), and the owner UID of the systemd user
197 unit or systemd session (if any) of the process the journal
198 entry originates from.</para>
199 </listitem>
200 </varlistentry>
201
202 <varlistentry>
203 <term><varname>_SELINUX_CONTEXT=</varname></term>
204 <listitem>
205 <para>The SELinux security context (label) of the process
206 the journal entry originates from.</para>
207 </listitem>
208 </varlistentry>
209
210 <varlistentry>
211 <term><varname>_SOURCE_REALTIME_TIMESTAMP=</varname></term>
212 <listitem>
213 <para>The earliest trusted timestamp of the message, if any
214 is known that is different from the reception time of the
215 journal. This is the time in microseconds since the epoch
216 UTC, formatted as a decimal string.</para>
217 </listitem>
218 </varlistentry>
219
220 <varlistentry>
221 <term><varname>_BOOT_ID=</varname></term>
222 <listitem>
223 <para>The kernel boot ID for the boot the message was
224 generated in, formatted as a 128-bit hexadecimal
225 string.</para>
226 </listitem>
227 </varlistentry>
228
229 <varlistentry>
230 <term><varname>_MACHINE_ID=</varname></term>
231 <listitem>
232 <para>The machine ID of the originating host, as available
233 in
234 <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>.</para>
235 </listitem>
236 </varlistentry>
237
238 <varlistentry>
239 <term><varname>_SYSTEMD_INVOCATION_ID=</varname></term>
240 <listitem>
241 <para>The invocation ID for the runtime cycle of the unit
242 the message was generated in, as available to processes
243 of the unit in <varname>$INVOCATION_ID</varname> (see
244 <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>).</para>
245 </listitem>
246 </varlistentry>
247
248 <varlistentry>
249 <term><varname>_HOSTNAME=</varname></term>
250 <listitem>
251 <para>The name of the originating host.</para>
252 </listitem>
253 </varlistentry>
254
255 <varlistentry>
256 <term><varname>_TRANSPORT=</varname></term>
257 <listitem>
258 <para>How the entry was received by the journal service.
259 Valid transports are:
260 </para>
261 <variablelist>
262 <varlistentry>
263 <term>
264 <option>audit</option>
265 </term>
266 <listitem>
267 <para>for those read from the kernel audit subsystem
268 </para>
269 </listitem>
270 </varlistentry>
271
272 <varlistentry>
273 <term>
274 <option>driver</option>
275 </term>
276 <listitem>
277 <para>for internally generated messages
278 </para>
279 </listitem>
280 </varlistentry>
281
282 <varlistentry>
283 <term>
284 <option>syslog</option>
285 </term>
286 <listitem>
287 <para>for those received via the local syslog socket
288 with the syslog protocol
289 </para>
290 </listitem>
291 </varlistentry>
292
293 <varlistentry>
294 <term>
295 <option>journal</option>
296 </term>
297 <listitem>
298 <para>for those received via the native journal
299 protocol
300 </para>
301 </listitem>
302 </varlistentry>
303
304 <varlistentry>
305 <term>
306 <option>stdout</option>
307 </term>
308 <listitem>
309 <para>for those read from a service's standard output
310 or error output
311 </para>
312 </listitem>
313 </varlistentry>
314
315 <varlistentry>
316 <term>
317 <option>kernel</option>
318 </term>
319 <listitem>
320 <para>for those read from the kernel
321 </para>
322 </listitem>
323 </varlistentry>
324 </variablelist>
325 </listitem>
326 </varlistentry>
327 <varlistentry>
328 <term><varname>_STREAM_ID=</varname></term>
329 <listitem>
330 <para>Only applies to <literal>_TRANSPORT=stdout</literal> records: specifies a randomized 128bit ID assigned
331 to the stream connection when it was first created. This ID is useful to reconstruct individual log streams
332 from the log records: all log records carrying the same stream ID originate from the same stream.</para>
333 </listitem>
334 </varlistentry>
335 <varlistentry>
336 <term><varname>_LINE_BREAK=</varname></term>
337 <listitem>
338 <para>Only applies to <literal>_TRANSPORT=stdout</literal> records: indicates that the log message in the
339 standard output/error stream was not terminated with a normal newline character (<literal>\n</literal>,
340 i.e. ASCII 10). Specifically, when set this field is one of <option>nul</option> (in case the line was
341 terminated by a NUL byte), <option>line-max</option> (in case the maximum log line length was reached, as
342 configured with <varname>LineMax=</varname> in
343 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>) or
344 <option>eof</option> (if this was the last log record of a stream and the stream ended without a final
345 newline character). Note that this record is not generated when a normal newline character was used for
346 marking the log line end.</para>
347 </listitem>
348 </varlistentry>
349 </variablelist>
350 </refsect1>
351
352 <refsect1>
353 <title>Kernel Journal Fields</title>
354
355 <para>Kernel fields are fields that are used by messages
356 originating in the kernel and stored in the journal.</para>
357
358 <variablelist class='journal-directives'>
359 <varlistentry>
360 <term><varname>_KERNEL_DEVICE=</varname></term>
361 <listitem>
362 <para>The kernel device name. If the entry is associated to
363 a block device, the major and minor of the device node,
364 separated by <literal>:</literal> and prefixed by
365 <literal>b</literal>. Similar for character devices but
366 prefixed by <literal>c</literal>. For network devices, this
367 is the interface index prefixed by <literal>n</literal>. For
368 all other devices, this is the subsystem name prefixed by
369 <literal>+</literal>, followed by <literal>:</literal>,
370 followed by the kernel device name.</para>
371 </listitem>
372 </varlistentry>
373 <varlistentry>
374 <term><varname>_KERNEL_SUBSYSTEM=</varname></term>
375 <listitem>
376 <para>The kernel subsystem name.</para>
377 </listitem>
378 </varlistentry>
379 <varlistentry>
380 <term><varname>_UDEV_SYSNAME=</varname></term>
381 <listitem>
382 <para>The kernel device name as it shows up in the device
383 tree below <filename>/sys</filename>.</para>
384 </listitem>
385 </varlistentry>
386 <varlistentry>
387 <term><varname>_UDEV_DEVNODE=</varname></term>
388 <listitem>
389 <para>The device node path of this device in
390 <filename>/dev</filename>.</para>
391 </listitem>
392 </varlistentry>
393 <varlistentry>
394 <term><varname>_UDEV_DEVLINK=</varname></term>
395 <listitem>
396 <para>Additional symlink names pointing to the device node
397 in <filename>/dev</filename>. This field is frequently set
398 more than once per entry.</para>
399 </listitem>
400 </varlistentry>
401 </variablelist>
402 </refsect1>
403
404 <refsect1>
405 <title>Fields to log on behalf of a different program</title>
406
407 <para>Fields in this section are used by programs to specify that
408 they are logging on behalf of another program or unit.
409 </para>
410
411 <para>Fields used by the <command>systemd-coredump</command>
412 coredump kernel helper:
413 </para>
414
415 <variablelist class='journal-directives'>
416 <varlistentry>
417 <term><varname>COREDUMP_UNIT=</varname></term>
418 <term><varname>COREDUMP_USER_UNIT=</varname></term>
419 <listitem>
420 <para>Used to annotate messages containing coredumps from
421 system and session units. See
422 <citerefentry><refentrytitle>coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>.
423 </para>
424 </listitem>
425 </varlistentry>
426 </variablelist>
427
428 <para>Privileged programs (currently UID 0) may attach
429 <varname>OBJECT_PID=</varname> to a message. This will instruct
430 <command>systemd-journald</command> to attach additional fields on
431 behalf of the caller:</para>
432
433 <variablelist class='journal-directives'>
434 <varlistentry>
435 <term><varname>OBJECT_PID=<replaceable>PID</replaceable></varname></term>
436 <listitem>
437 <para>PID of the program that this message pertains to.
438 </para>
439 </listitem>
440 </varlistentry>
441
442 <varlistentry>
443 <term><varname>OBJECT_UID=</varname></term>
444 <term><varname>OBJECT_GID=</varname></term>
445 <term><varname>OBJECT_COMM=</varname></term>
446 <term><varname>OBJECT_EXE=</varname></term>
447 <term><varname>OBJECT_CMDLINE=</varname></term>
448 <term><varname>OBJECT_AUDIT_SESSION=</varname></term>
449 <term><varname>OBJECT_AUDIT_LOGINUID=</varname></term>
450 <term><varname>OBJECT_SYSTEMD_CGROUP=</varname></term>
451 <term><varname>OBJECT_SYSTEMD_SESSION=</varname></term>
452 <term><varname>OBJECT_SYSTEMD_OWNER_UID=</varname></term>
453 <term><varname>OBJECT_SYSTEMD_UNIT=</varname></term>
454 <term><varname>OBJECT_SYSTEMD_USER_UNIT=</varname></term>
455 <listitem>
456 <para>These are additional fields added automatically by
457 <command>systemd-journald</command>. Their meaning is the
458 same as
459 <varname>_UID=</varname>,
460 <varname>_GID=</varname>,
461 <varname>_COMM=</varname>,
462 <varname>_EXE=</varname>,
463 <varname>_CMDLINE=</varname>,
464 <varname>_AUDIT_SESSION=</varname>,
465 <varname>_AUDIT_LOGINUID=</varname>,
466 <varname>_SYSTEMD_CGROUP=</varname>,
467 <varname>_SYSTEMD_SESSION=</varname>,
468 <varname>_SYSTEMD_UNIT=</varname>,
469 <varname>_SYSTEMD_USER_UNIT=</varname>, and
470 <varname>_SYSTEMD_OWNER_UID=</varname>
471 as described above, except that the process identified by
472 <replaceable>PID</replaceable> is described, instead of the
473 process which logged the message.</para>
474 </listitem>
475 </varlistentry>
476 </variablelist>
477
478 </refsect1>
479
480 <refsect1>
481 <title>Address Fields</title>
482
483 <para>During serialization into external formats, such as the
484 <ulink
485 url="https://www.freedesktop.org/wiki/Software/systemd/export">Journal
486 Export Format</ulink> or the <ulink
487 url="https://www.freedesktop.org/wiki/Software/systemd/json">Journal
488 JSON Format</ulink>, the addresses of journal entries are
489 serialized into fields prefixed with double underscores. Note that
490 these are not proper fields when stored in the journal but for
491 addressing metadata of entries. They cannot be written as part of
492 structured log entries via calls such as
493 <citerefentry><refentrytitle>sd_journal_send</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
494 They may also not be used as matches for
495 <citerefentry><refentrytitle>sd_journal_add_match</refentrytitle><manvolnum>3</manvolnum></citerefentry></para>
496
497 <variablelist class='journal-directives'>
498 <varlistentry>
499 <term><varname>__CURSOR=</varname></term>
500 <listitem>
501 <para>The cursor for the entry. A cursor is an opaque text
502 string that uniquely describes the position of an entry in
503 the journal and is portable across machines, platforms and
504 journal files.
505 </para>
506 </listitem>
507 </varlistentry>
508
509 <varlistentry>
510 <term><varname>__REALTIME_TIMESTAMP=</varname></term>
511 <listitem>
512 <para>The wallclock time
513 (<constant>CLOCK_REALTIME</constant>) at the point in time
514 the entry was received by the journal, in microseconds since
515 the epoch UTC, formatted as a decimal string. This has
516 different properties from
517 <literal>_SOURCE_REALTIME_TIMESTAMP=</literal>, as it is
518 usually a bit later but more likely to be monotonic.
519 </para>
520 </listitem>
521 </varlistentry>
522
523 <varlistentry>
524 <term><varname>__MONOTONIC_TIMESTAMP=</varname></term>
525 <listitem>
526 <para>The monotonic time
527 (<constant>CLOCK_MONOTONIC</constant>) at the point in time
528 the entry was received by the journal in microseconds,
529 formatted as a decimal string. To be useful as an address
530 for the entry, this should be combined with the boot ID in
531 <literal>_BOOT_ID=</literal>.
532 </para>
533 </listitem>
534 </varlistentry>
535 </variablelist>
536 </refsect1>
537
538 <refsect1>
539 <title>See Also</title>
540 <para>
541 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
542 <citerefentry><refentrytitle>journalctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
543 <citerefentry><refentrytitle>journald.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
544 <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
545 <citerefentry><refentrytitle>coredumpctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
546 <citerefentry><refentrytitle>systemd.directives</refentrytitle><manvolnum>7</manvolnum></citerefentry>
547 </para>
548 </refsect1>
549
550 </refentry>