Skip to content

[receiver/syslog] Support setting on_error mode for syslog receiver #37847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/syslog-receiver-add-error-mode.yaml
Original file line number Diff line number Diff line change
@@ -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]
18 changes: 9 additions & 9 deletions pkg/stanza/docs/operators/syslog_input.md
Original file line number Diff line number Diff line change
Expand Up @@ -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). |



Expand Down
4 changes: 4 additions & 0 deletions pkg/stanza/operator/input/syslog/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions pkg/stanza/operator/input/syslog/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/stanza/operator/input/syslog/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions receiver/syslogreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading