~ubuntu-branches/ubuntu/lucid/rsyslog/lucid

« back to all changes in this revision

Viewing changes to doc/syslog-protocol.html

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2007-10-19 17:21:49 UTC
  • Revision ID: james.westby@ubuntu.com-20071019172149-ie6ej2xve33mxiu7
Tags: upstream-1.19.10
ImportĀ upstreamĀ versionĀ 1.19.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<head>
 
3
<title>syslog-protocol support in rsyslog</title>
 
4
</head>
 
5
<body>
 
6
<h1>syslog-protocol support in rsyslog</h1>
 
7
<p><b><a href="http://www.rsyslog.com/">Rsyslog</a>&nbsp; provides a trial 
 
8
implementation of the proposed
 
9
<a href="http://www.monitorware.com/Common/en/glossary/syslog-protocol.php">
 
10
syslog-protocol</a> standard.</b> The intention of this implementation is to 
 
11
find out what inside syslog-protocol is causing problems during implementation. 
 
12
As syslog-protocol is a standard under development, its support in rsyslog is 
 
13
highly volatile. It may change from release to release. So while it provides 
 
14
some advantages in the real world, users are cautioned against using it right 
 
15
now. If you do, be prepared that you will probably need to update all of your 
 
16
rsyslogds with each new release. If you try it anyhow, please provide feedback 
 
17
as that would be most beneficial for us.</p>
 
18
<h2>Currently supported message format</h2>
 
19
<p>Due to recent discussion on syslog-protocol, we do not follow any specific 
 
20
revision of the draft but rather the candidate ideas. The format supported 
 
21
currently is:</p>
 
22
<p><b><code>&lt;PRI&gt;VERSION SP TIMESTAMP SP HOSTNAME SP APP-NAME SP PROCID SP MSGID SP [SD-ID]s 
 
23
SP MSG</code></b></p>
 
24
<p>Field syntax and semantics are as defined in IETF I-D syslog-protocol-15.</p>
 
25
<h2>Capabilities Implemented</h2>
 
26
<ul>
 
27
        <li>receiving message in the supported format (see above)</li>
 
28
        <li>sending messages in the supported format</li>
 
29
        <li>relaying messages</li>
 
30
        <li>receiving messages in either legacy or -protocol format and transforming 
 
31
        them into the other one</li>
 
32
        <li>virtual availability of TAG, PROCID, APP-NAME, MSGID, SD-ID no matter if 
 
33
        the message was received via legacy format, API or syslog-protocol format (non-present 
 
34
        fields are being emulated with great success)</li>
 
35
        <li>maximum message size is set via preprocessor #define</li>
 
36
        <li>syslog-protocol messages can be transmitted both over UDP and plain TCP 
 
37
        with some restrictions on compliance in the case of TCP</li>
 
38
</ul>
 
39
<h2>Findings</h2>
 
40
<p>This lists what has been found during implementation:</p>
 
41
<ul>
 
42
        <li>The same receiver must be able to support both legacy and 
 
43
        syslog-protocol syslog messages. Anything else would be a big inconvenience 
 
44
        to users and would make deployment much harder. The detection must be done 
 
45
        automatically (see below on how easy that is).</li>
 
46
        <li><b>NUL characters inside MSG</b> cause the message to be truncated at 
 
47
        that point. This is probably a major point for many C-based implementations. 
 
48
        No measures have yet been taken against this. Modifying the code to &quot;cleanly&quot; 
 
49
        support NUL characters is non-trivial, even though rsyslogd already has some 
 
50
        byte-counted string library (but this is new and not yet available 
 
51
        everywhere).</li>
 
52
        <li><b>character encoding in MSG</b>: is is problematic to do the right 
 
53
        UTF-8 encoding. The reason is that we pick up the MSG from the local domain 
 
54
        socket (which got it from the syslog(3) API). The text obtained does not 
 
55
        include any encoding information, but it does include non US-ASCII 
 
56
        characters. It may also include any other encoding. Other than by guessing 
 
57
        based on the provided text, I have no way to find out what it is. In order 
 
58
        to make the syslogd do anything useful, I have now simply taken the message 
 
59
        as is and stuffed it into the MSG part. Please note that I think this will 
 
60
        be a route that other implementors would take, too.</li>
 
61
        <li>A minimal parser is easy to implement. It took me roughly 2 hours to add 
 
62
        it to rsyslogd. This includes the time for restructuring the code to be able 
 
63
        to parse both legacy syslog as well as syslog-protocol. The parser has some 
 
64
        restrictions, though<ul>
 
65
        <li>STRUCTURED-DATA field is extracted, but not validated. Structured data 
 
66
        &quot;[test ]]&quot; is not caught as an error. Nor are any other errors caught. For 
 
67
        my needs with this syslogd, that level of structured data processing is 
 
68
        probably sufficient. I do not want to parse/validate it in all cases. This 
 
69
        is also a performance issue. I think other implementors could have the same 
 
70
        view. As such, we should not make validation a requirement.</li>
 
71
        <li>MSG is not further processed (e.g. Unicode not being validated)</li>
 
72
        <li>the other header fields are also extracted, but no validation is 
 
73
        performed right now. At least some validation should be easy to add (not 
 
74
        done this because it is a proof-of-concept and scheduled to change).</li>
 
75
</ul>
 
76
        </li>
 
77
        <li>Universal access to all syslog fields (missing ones being emulated) was 
 
78
        also quite easy. It took me around another 2 hours to integrate emulation of 
 
79
        non-present fields into the code base.</li>
 
80
        <li>The version at the start of the message makes it easy to detect if we 
 
81
        have legacy syslog or syslog-protocol. Do NOT move it to somewhere inside 
 
82
        the middle of the message, that would complicate things. It might not be 
 
83
        totally fail-safe to just rely on &quot;1 &quot; as the &quot;cookie&quot; for a syslog-protocol. 
 
84
        Eventually, it would be good to add some more uniqueness, e.g. &quot;@#1 &quot;.</li>
 
85
        <li>I have no (easy) way to detect truncation if that happens on the UDP 
 
86
        stack. All I see is that I receive e.g. a 4K message. If the message was e.g. 
 
87
        6K, I received two chunks. The first chunk (4K) is correctly detected as a 
 
88
        syslog-protocol message, the second (2K) as legacy syslog. I do not see what 
 
89
        we could do against this. This questions the usefulness of the TRUNCATE bit. 
 
90
        Eventually, I could look at the UDP headers and see that it is a fragment. I 
 
91
        have looked at a network sniffer log of the conversation. This looks like 
 
92
        two totally-independent messages were sent by the sender stack.</li>
 
93
        <li>The maximum message size is currently being configured via a 
 
94
        preprocessor #define. It can easily be set to 2K or 4K, but more than 4K is 
 
95
        not possible because of UDP stack limitations. Eventually, this can be 
 
96
        worked around, but I have not done this yet.</li>
 
97
        <li>rsyslogd can accept syslog-protocol formatted messages but is able to 
 
98
        relay them in legacy format. I find this a must in real-life deployments. 
 
99
        For this, I needed to do some field mapping so that APP-NAME/PROCID are 
 
100
        mapped into a TAG.</li>
 
101
        <li>rsyslogd can also accept legacy syslog message and relay them in 
 
102
        syslog-protocol format. For this, I needed to apply some sub-parsing of the 
 
103
        TAG, which on most occasions provides correct results. There might be some 
 
104
        misinterpretations but I consider these to be mostly non-intrusive. </li>
 
105
        <li>Messages received from the syslog API (the normal case under *nix) also 
 
106
        do not have APP-NAME and PROCID and I must parse them out of TAG as 
 
107
        described directly above. As such, this algorithm is absolutely vital to 
 
108
        make things work on *nix.</li>
 
109
        <li>I have an issue with messages received via the syslog(3) API (or, to be 
 
110
        more precise, via the local domain socket this API writes to): These 
 
111
        messages contain a timestamp, but that timestamp does neither have the year 
 
112
        nor the high-resolution time. The year is no real issue, I just take the 
 
113
        year of the reception of that message. There is a very small window of 
 
114
        exposure for messages read from the log immediately after midnight Jan 1st. 
 
115
        The message in the domain socket might have been written immediately before 
 
116
        midnight in the old year. I think this is acceptable. However, I can not 
 
117
        assign a high-precision timestamp, at least it is somewhat off if I take the 
 
118
        timestamp from message reception on the local socket. An alternative might 
 
119
        be to ignore the timestamp present and instead use that one when the message 
 
120
        is pulled from the local socket (I am talking about IPC, not the network - 
 
121
        just a reminder...). This is doable, but eventually not advisable. It looks 
 
122
        like this needs to be resolved via a configuration option.</li>
 
123
        <li>rsyslogd already advertised its origin information on application 
 
124
        startup (in a syslog-protocol-14 compatible format). It is fairly easy to 
 
125
        include that with any message if desired (not currently done).</li>
 
126
        <li>A big problem I noticed are malformed messages. In -syslog-protocol, we 
 
127
        recommend/require to discard malformed messages. However, in practice users 
 
128
        would like to see everything that the syslogd receives, even if it is in 
 
129
        error. For the first version, I have not included any error handling at all. 
 
130
        However, I think I would deliberately ignore any &quot;discard&quot; requirement. My 
 
131
        current point of view is that in my code I would eventually flag a message 
 
132
        as being invalid and allow the user to filter on this invalidness. So these 
 
133
        invalid messages could be redirected into special bins.</li>
 
134
        <li>The error logging recommendations (those I insisted on;)) are not really 
 
135
        practical. My application has its own error logging philosophy and I will 
 
136
        not change this to follow a draft.</li>
 
137
        <li>Relevance of support for leap seconds and senders without knowledge of 
 
138
        time is questionable. I have not made any specific provisions in the code 
 
139
        nor would I know how to handle that differently. I could, however, pull the 
 
140
        local reception timestamp in this case, so it might be useful to have this 
 
141
        feature. I do not think any more about this for the initial proof-of-concept. 
 
142
        Note it as a potential problem area, especially when logging to databases.</li>
 
143
        <li>The HOSTNAME field for internally generated messages currently contains 
 
144
        the hostname part only, not the FQDN. This can be changed inside the code 
 
145
        base, but it requires some thinking so that thinks are kept compatible with 
 
146
        legacy syslog. I have not done this for the proof-of-concept, but I think it 
 
147
        is not really bad. Maybe an hour or half a day of thinking.</li>
 
148
        <li>It is possible that I did not receive a TAG with legacy syslog or via 
 
149
        the syslog API. In this case, I can not generate the APP-NAME. For 
 
150
        consistency, I have used &quot;-&quot; in such cases (just like in PROCID, MSGID and 
 
151
        STRUCTURED-DATA).</li>
 
152
        <li>As an architectural side-effect, syslog-protocol formatted messages can 
 
153
        also be transmitted over non-standard syslog/raw tcp. This implementation 
 
154
        uses the industry-standard LF termination of tcp syslog records. As such, 
 
155
        syslog-protocol messages containing a LF will be broken invalidly. There is 
 
156
        nothing that can be done against this without specifying a TCP transport. 
 
157
        This issue might be more important than one thinks on first thought. The 
 
158
        reason is the wide deployment of syslog/tcp via industry standard.</li>
 
159
</ul>
 
160
<p><b>Some notes on syslog-transport-udp-06</b></p>
 
161
<ul>
 
162
        <li>I did not make any low-level modifications to the UDP code and think I 
 
163
        am still basically covered with this I-D.</li>
 
164
        <li>I deliberately violate section 3.3 insofar as that I do not necessarily 
 
165
        accept messages destined to port 514. This feature is user-required and a 
 
166
        must. The same applies to the destination port. I am not sure if the &quot;MUST&quot; 
 
167
        in section 3.3 was meant that this MUST be an option, but not necessarily be 
 
168
        active. The wording should be clarified.</li>
 
169
        <li>section 3.6: I do not check checksums. See the issue with discarding 
 
170
        messages above. The same solution will probably be applied in my code.</li>
 
171
</ul>
 
172
<p>&nbsp;</p>
 
173
<h2>Conlusions/Suggestions</h2>
 
174
<p>These are my personal conclusions and suggestions. Obviously, they must be 
 
175
discussed ;)</p>
 
176
<ul>
 
177
        <li>NUL should be disallowed in MSG</li>
 
178
        <li>As it is not possible to definitely know the character encoding of the 
 
179
        application-provided message, MSG should <b>not</b> be specified to use UTF-8 
 
180
        exclusively. Instead, it is suggested that any encoding may be used but 
 
181
        UTF-8 is preferred. To detect UTF-8, the MSG should start with the UTF-8 
 
182
        byte order mask of &quot;EF BB BF&quot; if it is UTF-8 encoded (see section 155.9 of
 
183
        <a href="http://www.unicode.org/versions/Unicode4.0.0/ch15.pdf">
 
184
        http://www.unicode.org/versions/Unicode4.0.0/ch15.pdf</a>) </li>
 
185
        <li>Requirements to drop messages should be reconsidered. I guess I would 
 
186
        not be the only implementor ignoring them.</li>
 
187
        <li>Logging requirements should be reconsidered and probably be removed.</li>
 
188
        <li>It would be advisable to specify &quot;-&quot; for APP-NAME is the name is not 
 
189
        known to the sender.</li>
 
190
        <li>The implications of the current syslog/tcp industry standard on 
 
191
        syslog-protocol should be further evaluated and be fully understood</li>
 
192
</ul>
 
193
<p>&nbsp;</p>
 
194
</body>
 
195
</html>
 
196