Skip to content

Commit

Permalink
Generate fields.go for netflow input
Browse files Browse the repository at this point in the history
* Generate fields.go for netflow input

Update x-pack/filebeat to generate a fields.go for each input type. And update the code that
generates the include/list.go to import each input.

* Fix netflow exporter version datatype

It was "int" which is not a valid type. Changed it to long rather than integer because we use that everywhere for numbers.

Cherry-pick parts of 01ae538 (elastic#9686)
  • Loading branch information
andrewkroh committed Dec 21, 2018
1 parent 74362ca commit ed43daf
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 8 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions x-pack/filebeat/filebeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,12 @@ filebeat.inputs:
# This option is not supported on Windows.
#filebeat.registry_file_permissions: 0600

# The timeout value that controls when registry entries are written to disk
# (flushed). When an unwritten update exceeds this value, it triggers a write to
# disk. When registry_flush is set to 0s, the registry is written to disk after
# each batch of events has been published successfully. The default value is 0s.
#filebeat.registry_flush: 0s

# By default Ingest pipelines are not updated if a pipeline with the same ID
# already exists. If this option is enabled Filebeat overwrites pipelines
# everytime a new Elasticsearch connection is established.
Expand Down
5 changes: 4 additions & 1 deletion x-pack/filebeat/include/list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x-pack/filebeat/input/netflow/_meta/fields.header.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
How long the exporter process has been running, in milliseconds.
- name: version
type: int
type: long
description: >
NetFlow version used.
2 changes: 1 addition & 1 deletion x-pack/filebeat/input/netflow/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
How long the exporter process has been running, in milliseconds.
- name: version
type: int
type: long
description: >
NetFlow version used.
Expand Down
22 changes: 22 additions & 0 deletions x-pack/filebeat/input/netflow/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions x-pack/filebeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func Build() error {
return mage.Build(mage.DefaultBuildArgs())
}

// GolangCrossBuild build the Beat binary inside of the golang-builder.
// GolangCrossBuild builds the Beat binary inside of the golang-builder.
// Do not use directly, use crossBuild instead.
func GolangCrossBuild() error {
return mage.GolangCrossBuild(mage.DefaultGolangCrossBuildArgs())
Expand All @@ -45,9 +45,18 @@ func CrossBuild() error {
return mage.CrossBuild()
}

// Fields generates a fields.yml and fields.go for each module.
// Fields generates the fields.yml file and a fields.go for each module and
// input.
func Fields() {
mg.Deps(fieldsYML, mage.GenerateModuleFieldsGo)
mg.Deps(fieldsYML, moduleFieldsGo, inputFieldsGo)
}

func inputFieldsGo() error {
return mage.GenerateModuleFieldsGo("input")
}

func moduleFieldsGo() error {
return mage.GenerateModuleFieldsGo("module")
}

// fieldsYML generates a fields.yml based on filebeat + x-pack/filebeat/modules.
Expand All @@ -65,9 +74,13 @@ func Config() {
mg.Deps(shortConfig, referenceConfig, createDirModulesD)
}

// Update is an alias for running fields, dashboards, config.
// Update is an alias for executing fields, dashboards, config.
func Update() {
mg.SerialDeps(Fields, Dashboards, Config)
mg.SerialDeps(Fields, Dashboards, Config, includeList)
}

func includeList() error {
return mage.GenerateIncludeListGo([]string{"input/*"}, []string{"module"})
}

// UnitTest executes the unit tests.
Expand Down

0 comments on commit ed43daf

Please sign in to comment.