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