Skip to content

Commit

Permalink
[netflow] Ensure custom fields configuration is applied (#40730) (#40739
Browse files Browse the repository at this point in the history
)

- Fix custom fields not being applied when provided through configuration
- Add regression test

(cherry picked from commit f9b41f2)

Co-authored-by: Taylor Swanson <90622908+taylor-swanson@users.noreply.github.com>
  • Loading branch information
mergify[bot] and taylor-swanson committed Sep 10, 2024
1 parent b17d69c commit 8704468
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff]
- Prevent GCP Pub/Sub input blockage by increasing default value of `max_outstanding_messages` {issue}35029[35029] {pull}38985[38985]
- Updated Websocket input title to align with existing inputs {pull}39006[39006]
- Fix publication of group data from the Okta entity analytics provider. {pull}40681[40681]
- Ensure netflow custom field configuration is applied. {issue}40735[40735] {pull}40730[40730]

*Heartbeat*

Expand Down
1 change: 1 addition & 0 deletions x-pack/filebeat/input/netflow/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (im *netflowInputManager) Create(cfg *conf.C) (v2.Input, error) {

input := &netflowInput{
cfg: inputCfg,
customFields: customFields,
internalNetworks: inputCfg.InternalNetworks,
logger: im.log,
queueSize: inputCfg.PacketQueueSize,
Expand Down
22 changes: 22 additions & 0 deletions x-pack/filebeat/input/netflow/input_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"

"github.com/elastic/beats/v7/libbeat/tests/resources"
"github.com/elastic/beats/v7/x-pack/filebeat/input/netflow/decoder/fields"

conf "github.com/elastic/elastic-agent-libs/config"
"github.com/elastic/elastic-agent-libs/logp"
Expand All @@ -29,3 +30,24 @@ func TestNewInputDone(t *testing.T) {
_, err = Plugin(logp.NewLogger("netflow_test")).Manager.Create(config)
require.NoError(t, err)
}

func TestConfig_CustomDefinitions(t *testing.T) {
goroutines := resources.NewGoroutinesChecker()
defer goroutines.Check(t)

wantDefinitions, err := LoadFieldDefinitionsFromFile("testdata/fields/netflow9_cisco_asa_custom.yaml")
require.NoError(t, err)
want := []fields.FieldDict{wantDefinitions}

config, err := conf.NewConfigFrom(mapstr.M{
"custom_definitions": []string{"testdata/fields/netflow9_cisco_asa_custom.yaml"},
})
require.NoError(t, err)

v2input, err := Plugin(logp.NewLogger("netflow_test")).Manager.Create(config)
require.NoError(t, err)

input := v2input.(*netflowInput)

require.EqualValues(t, input.customFields, want)
}

0 comments on commit 8704468

Please sign in to comment.