1SD_JOURNAL_GET_SEQNUM(3) sd_journal_get_seqnum SD_JOURNAL_GET_SEQNUM(3)
2
3
4
6 sd_journal_get_seqnum - Read sequence number from the current journal
7 entry
8
10 #include <systemd/sd-journal.h>
11
12 int sd_journal_get_seqnum(sd_journal *j, uint64_t *ret_seqnum,
13 sd_id128_t *ret_seqnum_id);
14
16 sd_journal_get_seqnum() returns the sequence number of the current
17 journal entry. It takes three arguments: the journal context object, a
18 pointer to a 64-bit unsigned integer to store the sequence number in,
19 and a buffer to return the 128-bit sequence number ID in.
20
21 When writing journal entries to disk each systemd-journald instance
22 will number them sequentially, starting from 1 for the first entry
23 written after subsystem initialization. Each such series of sequence
24 numbers is associated with a 128-bit sequence number ID which is
25 initialized randomly, once at systemd-journal initialization. Thus,
26 while multiple instances of systemd-journald will assign the same
27 sequence numbers to their written journal entries, they will have a
28 distinct sequence number IDs. The sequence number is assigned at the
29 moment of writing the entry to disk. If log entries are rewritten (for
30 example because the volatile logs from /run/log/ are flushed to
31 /var/log/ via systemd-journald-flush.service) they will get new
32 sequence numbers assigned.
33
34 Sequence numbers may be used to order entries (entries associated with
35 the same sequence number ID and lower sequence numbers should be
36 ordered chronologically before those with higher sequence numbers), and
37 to detect lost entries. Note that journal service instances typically
38 write to multiple journal files in parallel (for example because
39 SplitMode= is used), in which case each journal file will only contain
40 a subset of the sequence numbers. To recover the full stream of journal
41 entries the files must be combined ("interleaved"), a process that
42 primarily relies on the sequence numbers. When journal files are
43 rotated (due to size or time limits), the series of sequence numbers is
44 continued in the replacement files. All journal files generated from
45 the same journal instance will carry the same sequence number ID.
46
47 As the sequence numbers are assigned at the moment of writing the
48 journal entries to disk they do not exist if storage is disabled via
49 SplitMode=.
50
51 The ret_seqnum and ret_seqnum_id parameters may be specified as NULL in
52 which case the relevant data is not returned (but the call will
53 otherwise succeed).
54
55 Note that these functions will not work before sd_journal_next(3) (or
56 related call) has been called at least once, in order to position the
57 read pointer at a valid entry.
58
60 sd_journal_get_seqnum() returns 0 on success or a negative errno-style
61 error code..
62
64 All functions listed here are thread-agnostic and only a single
65 specific thread may operate on a given object during its entire
66 lifetime. It's safe to allocate multiple independent objects and use
67 each from a specific thread in parallel. However, it's not safe to
68 allocate such an object in one thread, and operate or free it from any
69 other, even if locking is used to ensure these threads don't operate on
70 it at the very same time.
71
72 Functions described here are available as a shared library, which can
73 be compiled against and linked to with the libsystemd pkg-config(1)
74 file.
75
77 systemd(1), sd-journal(3), sd_journal_open(3), sd_journal_next(3),
78 sd_journal_get_data(3), sd_journal_get_monotonic_usec(3)
79
80
81
82systemd 254 SD_JOURNAL_GET_SEQNUM(3)