You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[pkg/stanza] Option for setting max log size in syslog parser (#33777)
**Description:** add `MaxLogSize` parameter to `syslog` parser. Note
that for this option to be available, `enable_octet_counting` needs to
be set to `true`, as this is an option that is exclusive to the
`octetcounting` parser in the [syslog
library](github.com/leodido/go-syslog).
One aspect where I'm not sure about yet is regarding the placement of
the `max_log_size` option: Right now, this option is also set within the
`TCP` input configuration, whereas this new option would be one layer
above, i.e. in the syslog base config. This would mean that this option
could potentially be set to different values in the parser and tcp input
config like for example:
```
receivers:
syslog:
protocol: rfc5424
enable_octet_counting: true
max_log_size: 200000000 # 200MiB
tcp:
listen_address: :4278
max_log_size: 100000000 # 100MiB
exporters:
debug:
service:
pipelines:
logs:
receivers: [syslog]
exporters: [debug]
```
For now I have implemented this in a way where if nothing is set if the
tcp input config, the max_log_size value from the syslog base config
will be used. If set in the tcp config, the tcp input will use that more
specific value. To me this makes the most sense right now, but I
appreciate any feedback on this.
**Link to tracking Issue:** #33182
**Testing:** so far added unit test for the syslog parser, will also add
some tests for the syslog input config to test the behavior described
above.
**Documentation:** TODO, will add once we have figured out all open
questions
---------
Signed-off-by: Florian Bacher <[email protected]>
body:=`215 <86>1 2015-08-05T21:58:59.693Z 192.168.2.132 SecureAuth0 23108 ID52020 [SecureAuth@27389 UserHostAddress="192.168.2.132" Realm="SecureAuth0" UserID="Tester2" PEN="27389"] Found the user for retrieving user's profile`
91
+
92
+
set:=componenttest.NewNopTelemetrySettings()
93
+
op, err:=cfg.Build(set)
94
+
require.NoError(t, err)
95
+
96
+
fake:=testutil.NewFakeOutput(t)
97
+
err=op.SetOutputs([]operator.Operator{fake})
98
+
require.NoError(t, err)
99
+
100
+
newEntry:=entry.New()
101
+
newEntry.Body=body
102
+
err=op.Process(context.Background(), newEntry)
103
+
require.Error(t, err)
104
+
require.Contains(t, err.Error(), "message too long to parse. was size 215, max length 214")
105
+
106
+
select {
107
+
casee:=<-fake.Received:
108
+
require.Equal(t, body, e.Body)
109
+
case<-time.After(time.Second):
110
+
require.FailNow(t, "Timed out waiting for entry to be processed")
|`tcp`|`nil`| Defined tcp_input operator. (see the TCP configuration section) |
22
-
|`udp`|`nil`| Defined udp_input operator. (see the UDP configuration section) |
23
-
|`protocol`| required | The protocol to parse the syslog messages as. Options are `rfc3164` and `rfc5424`|
24
-
|`location`|`UTC`| The geographic location (timezone) to use when parsing the timestamp (Syslog RFC 3164 only). The available locations depend on the local IANA Time Zone database. [This page](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) contains many examples, such as `America/New_York`. |
25
-
|`enable_octet_counting`|`false`| Wether or not to enable [RFC 6587](https://www.rfc-editor.org/rfc/rfc6587#section-3.4.1) Octet Counting on syslog parsing (Syslog RFC 5424 and TCP only). |
26
-
|`allow_skip_pri_header`|`false`| Allow parsing records without the PRI header. If this setting is enabled, messages without the PRI header will be successfully parsed. The `SeverityNumber` and `SeverityText` fields as well as the `priority` and `facility` attributes will not be set on the log record. If this setting is disabled (the default), messages without PRI header will throw an exception. To set this setting to `true`, the `enable_octet_counting` setting must be `false`.|
27
-
|`non_transparent_framing_trailer`|`nil`| The framing trailer, either `LF` or `NUL`, when using [RFC 6587](https://www.rfc-editor.org/rfc/rfc6587#section-3.4.2) Non-Transparent-Framing (Syslog RFC 5424 and TCP only). |
28
-
|`attributes`| {} | A map of `key: value` labels to add to the entry's attributes |
29
-
|`resource`| {} | A map of `key: value` labels to add to the entry's resource |
30
-
|`operators`|[]| An array of [operators](../../pkg/stanza/docs/operators/README.md#what-operators-are-available). See below for more details |
31
-
|`retry_on_failure.enabled`|`false`| If `true`, the receiver will pause reading a file and attempt to resend the current batch of logs if it encounters an error from downstream components. |
32
-
|`retry_on_failure.initial_interval`|`1 second`| Time to wait after the first failure before retrying. |
33
-
|`retry_on_failure.max_interval`|`30 seconds`| Upper bound on retry backoff interval. Once this value is reached the delay between consecutive retries will remain constant at the specified value. |
34
-
|`retry_on_failure.max_elapsed_time`|`5 minutes`| Maximum amount of time (including retries) spent trying to send a logs batch to a downstream consumer. Once this value is reached, the data is discarded. Retrying never stops if set to `0`. |
|`tcp`|`nil`| Defined tcp_input operator. (see the TCP configuration section) |
22
+
|`udp`|`nil`| Defined udp_input operator. (see the UDP configuration section) |
23
+
|`protocol`| required | The protocol to parse the syslog messages as. Options are `rfc3164` and `rfc5424`|
24
+
|`location`|`UTC`| The geographic location (timezone) to use when parsing the timestamp (Syslog RFC 3164 only). The available locations depend on the local IANA Time Zone database. [This page](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) contains many examples, such as `America/New_York`. |
25
+
|`enable_octet_counting`|`false`| Wether or not to enable [RFC 6587](https://www.rfc-editor.org/rfc/rfc6587#section-3.4.1) Octet Counting on syslog parsing (Syslog RFC 5424 and TCP only). |
26
+
|`max_octets`|`8192`| The maximum octets for messages using [RFC 6587](https://www.rfc-editor.org/rfc/rfc6587#section-3.4.1) Octet Counting on syslog parsing (Syslog RFC 5424 and TCP only). |
27
+
|`allow_skip_pri_header`|`false`| Allow parsing records without the PRI header. If this setting is enabled, messages without the PRI header will be successfully parsed. The `SeverityNumber` and `SeverityText` fields as well as the `priority` and `facility` attributes will not be set on the log record. If this setting is disabled (the default), messages without PRI header will throw an exception. To set this setting to `true`, the `enable_octet_counting` setting must be `false`. |
28
+
|`non_transparent_framing_trailer`|`nil`| The framing trailer, either `LF` or `NUL`, when using [RFC 6587](https://www.rfc-editor.org/rfc/rfc6587#section-3.4.2) Non-Transparent-Framing (Syslog RFC 5424 and TCP only). |
29
+
|`attributes`| {} | A map of `key: value` labels to add to the entry's attributes |
30
+
|`resource`| {} | A map of `key: value` labels to add to the entry's resource |
31
+
|`operators`|[]| An array of [operators](../../pkg/stanza/docs/operators/README.md#what-operators-are-available). See below for more details |
32
+
|`retry_on_failure.enabled`|`false`| If `true`, the receiver will pause reading a file and attempt to resend the current batch of logs if it encounters an error from downstream components. |
33
+
|`retry_on_failure.initial_interval`|`1 second`| Time to wait after the first failure before retrying. |
34
+
|`retry_on_failure.max_interval`|`30 seconds`| Upper bound on retry backoff interval. Once this value is reached the delay between consecutive retries will remain constant at the specified value. |
35
+
|`retry_on_failure.max_elapsed_time`|`5 minutes`| Maximum amount of time (including retries) spent trying to send a logs batch to a downstream consumer. Once this value is reached, the data is discarded. Retrying never stops if set to `0`. |
0 commit comments