Skip to content

Commit 9d7bf1b

Browse files
authored
[receiver/syslog] Support setting on_error mode for syslog receiver (#37847)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description As per the discussion in #36906, this PR supports setting the `on_error` mode in syslog receiver that controls the behaviour of the underlying `syslog_parser` when it encounters an error. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Closes #36906. <!--Describe what testing was performed and which tests were added.--> #### Testing Tested setting `on_error` in the syslog receiver config. <!--Describe the documentation added.--> #### Documentation Documented the `on_error` entry in both the syslog input and receiver config. <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: Mengnan Gong <[email protected]>
1 parent 5879a03 commit 9d7bf1b

File tree

6 files changed

+43
-9
lines changed

6 files changed

+43
-9
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Use this changelog template to create an entry for release notes.
2+
3+
# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
4+
change_type: enhancement
5+
6+
# The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver)
7+
component: syslogreceiver
8+
9+
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
10+
note: Support setting `on_error` config for syslog receiver.
11+
12+
# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
13+
issues: [36906]
14+
15+
# (Optional) One or more lines of additional information to render under the primary note.
16+
# These lines will be padded with 2 spaces and then inserted directly into the document.
17+
# Use pipe (|) for multiline entries.
18+
subtext:
19+
20+
# If your change doesn't affect end users or the exported elements of any package,
21+
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
22+
# Optional: The change log or logs in which this entry should be included.
23+
# e.g. '[user]' or '[user, api]'
24+
# Include 'user' if the change is relevant to end users.
25+
# Include 'api' if there is a change to a library API.
26+
# Default: '[user]'
27+
change_logs: [user]

pkg/stanza/docs/operators/syslog_input.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ The `syslog_input` operator listens for syslog format logs from UDP/TCP packages
44

55
### Configuration Fields
66

7-
| Field | Default | Description |
8-
| --- | --- | --- |
9-
| `id` | `syslog_input` | A unique identifier for the operator. |
10-
| `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries. |
11-
| `tcp` | {} | A [tcp_input config](./tcp_input.md#configuration-fields) to defined syslog_parser operator. |
12-
| `udp` | {} | A [udp_input config](./udp_input.md#configuration-fields) to defined syslog_parser operator. |
7+
| Field | Default | Description |
8+
|--------------|------------------|-------------------------------------------------------------------------------------------------------|
9+
| `id` | `syslog_input` | A unique identifier for the operator. |
10+
| `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries. |
11+
| `tcp` | {} | A [tcp_input config](./tcp_input.md#configuration-fields) to defined syslog_parser operator. |
12+
| `udp` | {} | A [udp_input config](./udp_input.md#configuration-fields) to defined syslog_parser operator. |
1313
| `syslog` | required | A [syslog parser config](./syslog_parser.md#configuration-fields) to defined syslog_parser operator. |
14-
| `attributes` | {} | A map of `key: value` pairs to add to the entry's attributes. |
15-
| `resource` | {} | A map of `key: value` pairs to add to the entry's resource. |
16-
14+
| `attributes` | {} | A map of `key: value` pairs to add to the entry's attributes. |
15+
| `resource` | {} | A map of `key: value` pairs to add to the entry's resource. |
16+
| `on_error` | `send` | The behavior of the syslog parser if it encounters an error. See [on_error](../types/on_error.md). |
1717

1818

1919

pkg/stanza/operator/input/syslog/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ type Config struct {
3939
syslog.BaseConfig `mapstructure:",squash"`
4040
TCP *tcp.BaseConfig `mapstructure:"tcp"`
4141
UDP *udp.BaseConfig `mapstructure:"udp"`
42+
OnError string `mapstructure:"on_error"`
4243
}
4344

4445
func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error) {
@@ -52,6 +53,9 @@ func (c Config) Build(set component.TelemetrySettings) (operator.Operator, error
5253
syslogParserCfg.SetID(inputBase.ID() + "_internal_parser")
5354
syslogParserCfg.OutputIDs = c.OutputIDs
5455
syslogParserCfg.MaxOctets = c.MaxOctets
56+
if c.OnError != "" {
57+
syslogParserCfg.OnError = c.OnError
58+
}
5559
syslogParser, err := syslogParserCfg.Build(set)
5660
if err != nil {
5761
return nil, fmt.Errorf("failed to resolve syslog config: %w", err)

pkg/stanza/operator/input/syslog/config_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ func TestUnmarshal(t *testing.T) {
5757
cfg := NewConfig()
5858
cfg.Protocol = "rfc5424"
5959
cfg.Location = "foo"
60+
cfg.OnError = "send_quiet"
6061
cfg.UDP = &udp.NewConfig().BaseConfig
6162
cfg.UDP.ListenAddress = "10.0.0.1:9000"
6263
cfg.UDP.AddAttributes = true

pkg/stanza/operator/input/syslog/testdata/config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ udp:
2121
type: syslog_input
2222
protocol: rfc5424
2323
location: foo
24+
on_error: send_quiet
2425
udp:
2526
listen_address: 10.0.0.1:9000
2627
add_attributes: true

receiver/syslogreceiver/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Parses Syslogs received over TCP or UDP.
3333
| `retry_on_failure.initial_interval` | `1 second` | Time to wait after the first failure before retrying. |
3434
| `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. |
3535
| `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`. |
36+
| `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). |
3637

3738
### Operators
3839

0 commit comments

Comments
 (0)