diff --git a/.chloggen/syslog-receiver-add-error-mode.yaml b/.chloggen/syslog-receiver-add-error-mode.yaml new file mode 100644 index 000000000000..6d5ffb7043f3 --- /dev/null +++ b/.chloggen/syslog-receiver-add-error-mode.yaml @@ -0,0 +1,27 @@ +# Use this changelog template to create an entry for release notes. + +# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' +change_type: enhancement + +# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) +component: syslogreceiver + +# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). +note: Support setting `on_error` config for syslog receiver. + +# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. +issues: [36906] + +# (Optional) One or more lines of additional information to render under the primary note. +# These lines will be padded with 2 spaces and then inserted directly into the document. +# Use pipe (|) for multiline entries. +subtext: + +# If your change doesn't affect end users or the exported elements of any package, +# you should instead start your pull request title with [chore] or use the "Skip Changelog" label. +# Optional: The change log or logs in which this entry should be included. +# e.g. '[user]' or '[user, api]' +# Include 'user' if the change is relevant to end users. +# Include 'api' if there is a change to a library API. +# Default: '[user]' +change_logs: [user] diff --git a/pkg/stanza/docs/operators/syslog_input.md b/pkg/stanza/docs/operators/syslog_input.md index 596bad91028c..6c9909cb91b6 100644 --- a/pkg/stanza/docs/operators/syslog_input.md +++ b/pkg/stanza/docs/operators/syslog_input.md @@ -4,16 +4,16 @@ The `syslog_input` operator listens for syslog format logs from UDP/TCP packages ### Configuration Fields -| Field | Default | Description | -| --- | --- | --- | -| `id` | `syslog_input` | A unique identifier for the operator. | -| `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries. | -| `tcp` | {} | A [tcp_input config](./tcp_input.md#configuration-fields) to defined syslog_parser operator. | -| `udp` | {} | A [udp_input config](./udp_input.md#configuration-fields) to defined syslog_parser operator. | +| Field | Default | Description | +|--------------|------------------|-------------------------------------------------------------------------------------------------------| +| `id` | `syslog_input` | A unique identifier for the operator. | +| `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries. | +| `tcp` | {} | A [tcp_input config](./tcp_input.md#configuration-fields) to defined syslog_parser operator. | +| `udp` | {} | A [udp_input config](./udp_input.md#configuration-fields) to defined syslog_parser operator. | | `syslog` | required | A [syslog parser config](./syslog_parser.md#configuration-fields) to defined syslog_parser operator. | -| `attributes` | {} | A map of `key: value` pairs to add to the entry's attributes. | -| `resource` | {} | A map of `key: value` pairs to add to the entry's resource. | - +| `attributes` | {} | A map of `key: value` pairs to add to the entry's attributes. | +| `resource` | {} | A map of `key: value` pairs to add to the entry's resource. | +| `on_error` | `send` | The behavior of the syslog parser if it encounters an error. See [on_error](../types/on_error.md). | diff --git a/pkg/stanza/operator/input/syslog/config.go b/pkg/stanza/operator/input/syslog/config.go index 2ae316baef82..ca04694c15b0 100644 --- a/pkg/stanza/operator/input/syslog/config.go +++ b/pkg/stanza/operator/input/syslog/config.go @@ -39,6 +39,7 @@ type Config struct { syslog.BaseConfig `mapstructure:",squash"` TCP *tcp.BaseConfig `mapstructure:"tcp"` UDP *udp.BaseConfig `mapstructure:"udp"` + OnError string `mapstructure:"on_error"` } func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error) { @@ -52,6 +53,9 @@ func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error syslogParserCfg.SetID(inputBase.ID() + "_internal_parser") syslogParserCfg.OutputIDs = c.OutputIDs syslogParserCfg.MaxOctets = c.MaxOctets + if c.OnError != "" { + syslogParserCfg.OnError = c.OnError + } syslogParser, err := syslogParserCfg.Build(set) if err != nil { return nil, fmt.Errorf("failed to resolve syslog config: %w", err) diff --git a/pkg/stanza/operator/input/syslog/config_test.go b/pkg/stanza/operator/input/syslog/config_test.go index b24792726c35..9f9f8998aa60 100644 --- a/pkg/stanza/operator/input/syslog/config_test.go +++ b/pkg/stanza/operator/input/syslog/config_test.go @@ -57,6 +57,7 @@ func TestUnmarshal(t *testing.T) { cfg := NewConfig() cfg.Protocol = "rfc5424" cfg.Location = "foo" + cfg.OnError = "send_quiet" cfg.UDP = &udp.NewConfig().BaseConfig cfg.UDP.ListenAddress = "10.0.0.1:9000" cfg.UDP.AddAttributes = true diff --git a/pkg/stanza/operator/input/syslog/testdata/config.yaml b/pkg/stanza/operator/input/syslog/testdata/config.yaml index 59e40b5ecfd5..f26c1f3c8844 100644 --- a/pkg/stanza/operator/input/syslog/testdata/config.yaml +++ b/pkg/stanza/operator/input/syslog/testdata/config.yaml @@ -21,6 +21,7 @@ udp: type: syslog_input protocol: rfc5424 location: foo + on_error: send_quiet udp: listen_address: 10.0.0.1:9000 add_attributes: true diff --git a/receiver/syslogreceiver/README.md b/receiver/syslogreceiver/README.md index 98285aad26a0..26e7e05f15b2 100644 --- a/receiver/syslogreceiver/README.md +++ b/receiver/syslogreceiver/README.md @@ -33,6 +33,7 @@ Parses Syslogs received over TCP or UDP. | `retry_on_failure.initial_interval` | `1 second` | Time to wait after the first failure before retrying. | | `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. | | `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`. | +| `on_error` | `send` | The behavior of the [syslog parser](../../pkg/stanza/docs/operators/syslog_parser.md) if it encounters an error. See [on_error](../../pkg/stanza/docs/types/on_error.md). | ### Operators