From 4ba26663f20ed5b8fedfb97e6c97defcc30b5a26 Mon Sep 17 00:00:00 2001 From: rockb1017 Date: Fri, 27 Aug 2021 13:53:46 -0700 Subject: [PATCH 1/3] unit and priority config --- operator/builtin/input/journald/journald.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/operator/builtin/input/journald/journald.go b/operator/builtin/input/journald/journald.go index 9c90c6ae..1d490f70 100644 --- a/operator/builtin/input/journald/journald.go +++ b/operator/builtin/input/journald/journald.go @@ -44,6 +44,7 @@ func NewJournaldInputConfig(operatorID string) *JournaldInputConfig { return &JournaldInputConfig{ InputConfig: helper.NewInputConfig(operatorID, "journald_input"), StartAt: "end", + Priority: "info", } } @@ -54,6 +55,8 @@ type JournaldInputConfig struct { Directory *string `mapstructure:"directory,omitempty" json:"directory,omitempty" yaml:"directory,omitempty"` Files []string `mapstructure:"files,omitempty" json:"files,omitempty" yaml:"files,omitempty"` StartAt string `mapstructure:"start_at,omitempty" json:"start_at,omitempty" yaml:"start_at,omitempty"` + Units []string `mapstructure:"units,omitempty" json:"units,omitempty" yaml:"units,omitempty"` + Priority string `mapstructure:"priority,omitempty" json:"priority,omitempty" yaml:"priority,omitempty"` } // Build will build a journald input operator from the supplied configuration @@ -82,6 +85,12 @@ func (c JournaldInputConfig) Build(buildContext operator.BuildContext) ([]operat return nil, fmt.Errorf("invalid value '%s' for parameter 'start_at'", c.StartAt) } + for _, unit := range c.Units { + args = append(args, "--unit=", unit) + } + + args = append(args, "--priority", c.Priority) + switch { case c.Directory != nil: args = append(args, "--directory", *c.Directory) From c12d0c22f7a53d04d47f9a65df776526d760a2f3 Mon Sep 17 00:00:00 2001 From: rockb1017 Date: Fri, 27 Aug 2021 16:09:25 -0700 Subject: [PATCH 2/3] doc update --- docs/operators/journald_input.md | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/operators/journald_input.md b/docs/operators/journald_input.md index c7127fbb..1e3336b0 100644 --- a/docs/operators/journald_input.md +++ b/docs/operators/journald_input.md @@ -14,13 +14,26 @@ The `journald_input` operator will use the `__REALTIME_TIMESTAMP` field of the j | `output` | Next in pipeline | The connected operator(s) that will receive all outbound entries | | `directory` | | A directory containing journal files to read entries from | | `files` | | A list of journal files to read entries from | -| `write_to` | `$body` | The body [field](/docs/types/field.md) written to when creating a new log entry | +| `units` | | A list of units to read entries from | +| `priority` | `info` | Filter output by message priorities or priority ranges | +| `write_to` | `$body` | The body [field](/docs/types/field.md) written to when creating a new log entry | | `start_at` | `end` | At startup, where to start reading logs from the file. Options are `beginning` or `end` | -| `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 | ### Example Configurations +```yaml +- type: journald_input + units: + - ssh + - kubelet + priority: info +``` +```yaml +- type: journald_input + priority: emerg..err +``` #### Simple journald input Configuration: From f296a3f589e529380b70737b33c36a1b4bdd34e2 Mon Sep 17 00:00:00 2001 From: rockb1017 Date: Fri, 27 Aug 2021 16:58:40 -0700 Subject: [PATCH 3/3] clean up --- operator/builtin/input/journald/journald.go | 6 +++--- operator/builtin/input/journald/journald_test.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/operator/builtin/input/journald/journald.go b/operator/builtin/input/journald/journald.go index 1d490f70..6a69a0ce 100644 --- a/operator/builtin/input/journald/journald.go +++ b/operator/builtin/input/journald/journald.go @@ -44,7 +44,7 @@ func NewJournaldInputConfig(operatorID string) *JournaldInputConfig { return &JournaldInputConfig{ InputConfig: helper.NewInputConfig(operatorID, "journald_input"), StartAt: "end", - Priority: "info", + Priority: "info", } } @@ -55,7 +55,7 @@ type JournaldInputConfig struct { Directory *string `mapstructure:"directory,omitempty" json:"directory,omitempty" yaml:"directory,omitempty"` Files []string `mapstructure:"files,omitempty" json:"files,omitempty" yaml:"files,omitempty"` StartAt string `mapstructure:"start_at,omitempty" json:"start_at,omitempty" yaml:"start_at,omitempty"` - Units []string `mapstructure:"units,omitempty" json:"units,omitempty" yaml:"units,omitempty"` + Units []string `mapstructure:"units,omitempty" json:"units,omitempty" yaml:"units,omitempty"` Priority string `mapstructure:"priority,omitempty" json:"priority,omitempty" yaml:"priority,omitempty"` } @@ -86,7 +86,7 @@ func (c JournaldInputConfig) Build(buildContext operator.BuildContext) ([]operat } for _, unit := range c.Units { - args = append(args, "--unit=", unit) + args = append(args, "--unit", unit) } args = append(args, "--priority", c.Priority) diff --git a/operator/builtin/input/journald/journald_test.go b/operator/builtin/input/journald/journald_test.go index 913683f4..d9197ceb 100644 --- a/operator/builtin/input/journald/journald_test.go +++ b/operator/builtin/input/journald/journald_test.go @@ -124,6 +124,7 @@ func TestJournaldInputConfig(t *testing.T) { input := map[string]interface{}{ "id": "my_journald_input", "type": "journald_input", + "priority": "info", "start_at": "end", "write_to": "$body.to", "attributes": map[string]interface{}{},