Skip to content
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

[WIP] Rename prospector to input #5944

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
78107fc
First step of refactoring move file into an input package
ph Dec 12, 2017
fea2be3
Rename Prospector interface to input
ph Dec 12, 2017
9cd712f
Rename Prospectorer struct to InputRunner
ph Dec 12, 2017
8d8719e
Rename prospectorConfig to inputConfig
ph Dec 12, 2017
9d9b63f
rename variables
ph Dec 12, 2017
7d5748a
change variables
ph Dec 12, 2017
87360a8
inputrunner -> runner
ph Dec 13, 2017
a403fe3
Retricts go version to build the backward compatibility layer
ph Dec 19, 2017
7978674
rename prospector -> input
ph Dec 19, 2017
d3b7b84
prospector -> input
ph Dec 19, 2017
3728c00
more rename prospector -> input
ph Dec 19, 2017
53d4026
Renaming prospector -> input
ph Dec 19, 2017
be47d56
rename prospector -> input
ph Dec 19, 2017
d8ec7e5
prospector -> input
ph Dec 19, 2017
1f10990
prospector -> input
ph Dec 19, 2017
6bf250c
prospector -> input
ph Dec 19, 2017
e4e0db1
prospector -> input
ph Dec 19, 2017
fb470ef
prospector -> input
ph Dec 19, 2017
aa66a55
rename prospector -> input
ph Dec 19, 2017
c04bb35
prospector -> input
ph Dec 19, 2017
4834d76
prospector -> input
ph Dec 19, 2017
ef85195
make it configurable
ph Dec 20, 2017
8d2d4b1
Fileset correctly migrate from prospector to input
ph Dec 20, 2017
32d179e
pluginKey from prospector to input
ph Dec 20, 2017
743acbc
Allow module manifest to define either an input or a prospector
ph Dec 20, 2017
7e703a8
Backward compatibility last fixes
ph Dec 21, 2017
aa09e39
Add the input to the event data
ph Dec 21, 2017
bc475e1
Move the prospector into input
ph Dec 21, 2017
fa832c3
rename the main prospector.go to input.go
ph Dec 21, 2017
9e1534b
Migrate: Log prospect to the input interace and rename prospector to
ph Dec 21, 2017
0c9fea4
Migrate: STDIN prospector to the input interface
ph Dec 21, 2017
5070dbb
Migrate: UDP prospector the input interface
ph Dec 21, 2017
112ff25
Migrate: Redis prospector to the input interface
ph Dec 21, 2017
13d32d0
Migrate: Docker prospector to input interface
ph Dec 21, 2017
ff48fab
Merge with previous commit for docker
ph Dec 21, 2017
57d6e43
Rename test_prospector.py
ph Dec 21, 2017
2042c8c
merge with previous commit
ph Dec 21, 2017
a47c88c
Module: traefik, prospector -> input
ph Dec 21, 2017
7e79aec
Migrate: Traefik json expectation
ph Dec 21, 2017
cc93de3
Migrate: Module system yaml prospector -> input
ph Dec 21, 2017
b93715b
Migrate: System json prospector -> input
ph Dec 21, 2017
00028ff
Migrate: Redis prospector -> input
ph Dec 21, 2017
afc3219
Migrate: Redis json prospector -> input
ph Dec 21, 2017
b81f280
Migrate: Postgresql prospector -> input yaml
ph Dec 21, 2017
db7ef32
Migrate: postgresql prospector -> input (json)
ph Dec 21, 2017
eb3faef
Migrate: nginx prospector -> input (yaml)
ph Dec 21, 2017
791a5d2
Migrate: nginx prospector -> input (json)
ph Dec 21, 2017
250daf9
Migrate: mysql prospector -> input (yaml)
ph Dec 21, 2017
c65a132
Migrate: logstash prospector -> input (yaml)
ph Dec 21, 2017
c5731d3
Migrate: Logstash module prospector -> input (json)
ph Dec 21, 2017
1478e5d
Migrate: Kafka module prospector -> input (yaml)
ph Dec 21, 2017
7e87955
Migrate: Kafka module prospector -> input (json)
ph Dec 21, 2017
a6ac2e8
Migrate: icinga module prospector -> input (yaml)
ph Dec 21, 2017
7d68769
Migrate: icinga module prospector -> input (json)
ph Dec 21, 2017
7fa797b
Migrate: Auditd module prospector -> input (yaml)
ph Dec 21, 2017
bd3ff74
Migrate: Auditd module prospector -> input (json)
ph Dec 21, 2017
0b80320
Migrate: apache2 module prospector -> input (yaml)
ph Dec 21, 2017
edfe266
Migrate: apache2 module prospector -> input (json)
ph Dec 21, 2017
52682a5
Update filebeat yml files and template for inputs
ph Dec 21, 2017
4c8fdd9
Add input.type field and keep prospector.type for backward compatibility
ph Dec 21, 2017
6501bed
Adjust the import generator to check into the input folder instead and
ph Dec 21, 2017
0af0e45
missing changing packages
ph Dec 21, 2017
825831e
Adjust docker compose to find the docker file into the new directory
ph Dec 22, 2017
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
12 changes: 6 additions & 6 deletions filebeat/_meta/common.p2.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# For more available modules and options, please see the filebeat.reference.yml sample
# configuration file.

#=========================== Filebeat prospectors =============================
#=========================== Filebeat inputs =============================

filebeat.prospectors:
filebeat.inputs:

# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.
# Each - is an input. Most options can be set at the input level, so
# you can use different input for various configurations.
# Below are the input specific configurations.

- type: log

# Change to true to enable this prospector configuration.
# Change to true to enable this input configuration.
enabled: false

# Paths that should be crawled and fetched. Glob based paths.
Expand Down
44 changes: 22 additions & 22 deletions filebeat/_meta/common.reference.p2.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#=========================== Filebeat prospectors =============================
#=========================== Filebeat inputs =============================

# List of prospectors to fetch data.
filebeat.prospectors:
# Each - is a prospector. Most options can be set at the prospector level, so
# you can use different prospectors for various configurations.
# Below are the prospector specific configurations.
# List of input to fetch data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say inputs (plural)

filebeat.inputs:
# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.

# Type of the files. Based on this the way the file is read is decided.
# The different types cannot be mixed in one prospector
# The different types cannot be mixed in one input
#
# Possible options are:
# * log: Reads every line of the log file (default)
# * stdin: Reads the standard in

#------------------------------ Log prospector --------------------------------
#------------------------------ Log input --------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change this to say "Input" instead of "Log input" given the various types we now support?

- type: log

# Change to true to enable this prospector configuration.
# Change to true to enable this input configuration.
enabled: false

# Paths that should be crawled and fetched. Glob based paths.
Expand Down Expand Up @@ -67,7 +67,7 @@ filebeat.prospectors:
# Time strings like 2h (2 hours), 5m (5 minutes) can be used.
#ignore_older: 0

# How often the prospector checks for new files in the paths that are specified
# How often the input checks for new files in the paths that are specified
# for harvesting. Specify 1s to scan the directory as frequently as possible
# without causing Filebeat to scan too frequently. Default: 10s.
#scan_frequency: 10s
Expand Down Expand Up @@ -137,7 +137,7 @@ filebeat.prospectors:
# this can mean that the first entries of a new file are skipped.
#tail_files: false

# The Ingest Node pipeline ID associated with this prospector. If this is set, it
# The Ingest Node pipeline ID associated with this input. If this is set, it
# overwrites the pipeline option from the Elasticsearch output.
#pipeline:

Expand Down Expand Up @@ -203,23 +203,23 @@ filebeat.prospectors:
# Note: Potential data loss. Make sure to read and understand the docs for this option.
#close_timeout: 0

# Defines if prospectors is enabled
# Defines if input is enabled
#enabled: true

#----------------------------- Stdin prospector -------------------------------
#----------------------------- Stdin input -------------------------------
# Configuration to use stdin input
#- type: stdin

#------------------------- Redis slowlog prospector ---------------------------
# Experimental: Config options for the redis slow log prospector
#------------------------- Redis slowlog input ---------------------------
# Experimental: Config options for the redis slow log input
#- type: redis
#hosts: ["localhost:6379"]
#username:
#password:
#enabled: false
#scan_frequency: 10s

# Timeout after which time the prospector should return an error
# Timeout after which time the input should return an error
#timeout: 1s

# Network type to be used for redis connection. Default: tcp
Expand All @@ -231,8 +231,8 @@ filebeat.prospectors:
# Redis AUTH password. Empty by default.
#password: foobared

#------------------------------ Udp prospector --------------------------------
# Experimental: Config options for the udp prospector
#------------------------------ Udp input --------------------------------
# Experimental: Config options for the udp input
#- type: udp

# Maximum size of the message received over UDP
Expand All @@ -241,7 +241,7 @@ filebeat.prospectors:
#========================== Filebeat autodiscover ==============================

# Autodiscover allows you to detect changes in the system and spawn new modules
# or prospectors as they happen.
# or inputs as they happen.

#filebeat.autodiscover:
# List of enabled autodiscover providers
Expand All @@ -262,7 +262,7 @@ filebeat.prospectors:
#filebeat.registry_file: ${path.data}/registry

# These config files must have the full filebeat config part inside, but only
# the prospector part is processed. All global options like spool_size are ignored.
# the input part is processed. All global options like spool_size are ignored.
# The config_dir MUST point to a different directory then where the main filebeat config file is in.
#filebeat.config_dir:

Expand All @@ -272,9 +272,9 @@ filebeat.prospectors:

# Enable filebeat config reloading
#filebeat.config:
#prospectors:
#inputs:
#enabled: false
#path: prospectors.d/*.yml
#path: inputs.d/*.yml
#reload.enabled: true
#reload.period: 10s
#modules:
Expand Down
7 changes: 6 additions & 1 deletion filebeat/_meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@
- name: prospector.type
required: true
description: >
The prospector type from which the event was generated. This field is set to the value specified for the `type` option in the prospector section of the Filebeat config file.
The input type from which the event was generated. This field is set to the value specified for the `type` option in the input section of the Filebeat config file.

- name: input.type
required: true
description: >
The input type from which the event was generated. This field is set to the value specified for the `type` option in the input section of the Filebeat config file.

- name: read_timestamp
description: >
Expand Down
18 changes: 9 additions & 9 deletions filebeat/beater/autodiscover.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ import (
"github.com/elastic/beats/libbeat/common/bus"
)

// AutodiscoverAdapter for Filebeat modules & prospectors
// AutodiscoverAdapter for Filebeat modules & input
type AutodiscoverAdapter struct {
prospectorFactory cfgfile.RunnerFactory
moduleFactory cfgfile.RunnerFactory
inputFactory cfgfile.RunnerFactory
moduleFactory cfgfile.RunnerFactory
}

// NewAutodiscoverAdapter builds and returns an autodiscover adapter for Filebeat modules & prospectors
func NewAutodiscoverAdapter(prospectorFactory, moduleFactory cfgfile.RunnerFactory) *AutodiscoverAdapter {
// NewAutodiscoverAdapter builds and returns an autodiscover adapter for Filebeat modules & input
func NewAutodiscoverAdapter(inputFactory, moduleFactory cfgfile.RunnerFactory) *AutodiscoverAdapter {
return &AutodiscoverAdapter{
prospectorFactory: prospectorFactory,
moduleFactory: moduleFactory,
inputFactory: inputFactory,
moduleFactory: moduleFactory,
}
}

Expand All @@ -37,12 +37,12 @@ func (m *AutodiscoverAdapter) CheckConfig(c *common.Config) error {
return nil
}

// Create a module or prospector from the given config
// Create a module or input from the given config
func (m *AutodiscoverAdapter) Create(c *common.Config, meta *common.MapStrPointer) (cfgfile.Runner, error) {
if c.HasField("module") {
return m.moduleFactory.Create(c, meta)
}
return m.prospectorFactory.Create(c, meta)
return m.inputFactory.Create(c, meta)
}

// StartFilter returns the bus filter to retrieve runner start triggering events
Expand Down
38 changes: 23 additions & 15 deletions filebeat/beater/filebeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ func New(b *beat.Beat, rawConfig *common.Config) (beat.Beater, error) {
return nil, err
}

if len(config.Prospectors) > 0 {
cfgwarn.Deprecate("7.0.0", "prospectors are deprecated, Use `inputs` instead.")
if len(config.Inputs) > 0 {
return nil, fmt.Errorf("prospectors and inputs used in the configuration file, define only inputs not both")
}
config.Inputs = config.Prospectors
}

moduleRegistry, err := fileset.NewModuleRegistry(config.Modules, b.Info.Version, true)
if err != nil {
return nil, err
Expand All @@ -62,7 +70,7 @@ func New(b *beat.Beat, rawConfig *common.Config) (beat.Beater, error) {
logp.Info("Enabled modules/filesets: %s", moduleRegistry.InfoString())
}

moduleProspectors, err := moduleRegistry.GetProspectorConfigs()
moduleInputs, err := moduleRegistry.GetInputConfigs()
if err != nil {
return nil, err
}
Expand All @@ -71,28 +79,28 @@ func New(b *beat.Beat, rawConfig *common.Config) (beat.Beater, error) {
return nil, err
}

// Add prospectors created by the modules
config.Prospectors = append(config.Prospectors, moduleProspectors...)
// Add inputs created by the modules
config.Inputs = append(config.Inputs, moduleInputs...)

haveEnabledProspectors := false
for _, prospector := range config.Prospectors {
if prospector.Enabled() {
haveEnabledProspectors = true
haveEnabledInputs := false
for _, input := range config.Inputs {
if input.Enabled() {
haveEnabledInputs = true
break
}
}

if !config.ConfigProspector.Enabled() && !config.ConfigModules.Enabled() && !haveEnabledProspectors && config.Autodiscover == nil {
if !config.ConfigInput.Enabled() && !config.ConfigModules.Enabled() && !haveEnabledInputs && config.Autodiscover == nil {
if !b.InSetupCmd {
return nil, errors.New("No modules or prospectors enabled and configuration reloading disabled. What files do you want me to watch?")
return nil, errors.New("no modules or inputs enabled and configuration reloading disabled. What files do you want me to watch?")
}

// in the `setup` command, log this only as a warning
logp.Warn("Setup called, but no modules enabled.")
}

if *once && config.ConfigProspector.Enabled() && config.ConfigModules.Enabled() {
return nil, errors.New("prospector configs and -once cannot be used together")
if *once && config.ConfigInput.Enabled() && config.ConfigModules.Enabled() {
return nil, errors.New("input configs and -once cannot be used together")
}

fb := &Filebeat{
Expand Down Expand Up @@ -220,7 +228,7 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
outDone := make(chan struct{}) // outDone closes down all active pipeline connections
crawler, err := crawler.New(
channel.NewOutletFactory(outDone, b.Publisher, wgEvents).Create,
config.Prospectors,
config.Inputs,
b.Info.Version,
fb.done,
*once)
Expand Down Expand Up @@ -261,7 +269,7 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
logp.Warn(pipelinesWarning)
}

err = crawler.Start(registrar, config.ConfigProspector, config.ConfigModules, pipelineLoaderFactory)
err = crawler.Start(registrar, config.ConfigInput, config.ConfigModules, pipelineLoaderFactory)
if err != nil {
crawler.Stop()
return err
Expand All @@ -279,7 +287,7 @@ func (fb *Filebeat) Run(b *beat.Beat) error {

var adiscover *autodiscover.Autodiscover
if fb.config.Autodiscover != nil {
adapter := NewAutodiscoverAdapter(crawler.ProspectorsFactory, crawler.ModulesFactory)
adapter := NewAutodiscoverAdapter(crawler.InputsFactory, crawler.ModulesFactory)
adiscover, err = autodiscover.NewAutodiscover("filebeat", adapter, config.Autodiscover)
if err != nil {
return err
Expand All @@ -291,7 +299,7 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
waitFinished.AddChan(fb.done)
waitFinished.Wait()

// Stop autodiscover -> Stop crawler -> stop prospectors -> stop harvesters
// Stop autodiscover -> Stop crawler -> stop inputs -> stop harvesters
// Note: waiting for crawlers to stop here in order to install wgEvents.Wait
// after all events have been enqueued for publishing. Otherwise wgEvents.Wait
// or publisher might panic due to concurrent updates.
Expand Down
17 changes: 10 additions & 7 deletions filebeat/channel/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ type clientEventer struct {
wgEvents eventCounter
}

// prospectorOutletConfig defines common prospector settings
// inputOutletConfig defines common input settings
// for the publisher pipline.
type prospectorOutletConfig struct {
type inputOutletConfig struct {
// event processing
common.EventMetadata `config:",inline"` // Fields and tags to add to events.
Processors processors.PluginConfig `config:"processors"`

// implicit event fields
Type string `config:"type"` // prospector.type
Type string `config:"type"` // input.type

// hidden filebeat modules settings
Module string `config:"_module_name"` // hidden setting
Expand All @@ -44,7 +44,7 @@ type prospectorOutletConfig struct {
}

// NewOutletFactory creates a new outlet factory for
// connecting a prospector to the publisher pipeline.
// connecting an input to the publisher pipeline.
func NewOutletFactory(
done <-chan struct{},
pipeline beat.Pipeline,
Expand All @@ -63,12 +63,12 @@ func NewOutletFactory(
return o
}

// Create builds a new Outleter, while applying common prospector settings.
// Prospectors and all harvesters use the same pipeline client instance.
// Create builds a new Outleter, while applying common input settings.
// Inputs and all harvesters use the same pipeline client instance.
// This guarantees ordering between events as required by the registrar for
// file.State updates
func (f *OutletFactory) Create(cfg *common.Config, dynFields *common.MapStrPointer) (Outleter, error) {
config := prospectorOutletConfig{}
config := inputOutletConfig{}
if err := cfg.Unpack(&config); err != nil {
return nil, err
}
Expand Down Expand Up @@ -99,6 +99,9 @@ func (f *OutletFactory) Create(cfg *common.Config, dynFields *common.MapStrPoint
fields["prospector"] = common.MapStr{
"type": config.Type,
}
fields["input"] = common.MapStr{
"type": config.Type,
}
}

client, err := f.pipeline.ConnectWith(beat.ClientConfig{
Expand Down
2 changes: 1 addition & 1 deletion filebeat/channel/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
// Factory is used to create a new Outlet instance
type Factory func(*common.Config, *common.MapStrPointer) (Outleter, error)

// Outleter is the outlet for a prospector
// Outleter is the outlet for an input
type Outleter interface {
Close() error
OnEvent(data *util.Data) bool
Expand Down
Loading