Skip to content

Commit

Permalink
Make winlogbeat accept the new top-level settings
Browse files Browse the repository at this point in the history
The list has grown quite long, switching to ucfg validation for this would be nice.
Also added explicit key names to config.
  • Loading branch information
Tudor Golubenco committed May 9, 2016
1 parent 6b7dd17 commit 845cd14
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
10 changes: 5 additions & 5 deletions libbeat/beat/beat.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ type Beat struct {

// BeatConfig struct contains the basic configuration of every beat
type BeatConfig struct {
Output map[string]*common.Config
Logging logp.Logging
Shipper publisher.ShipperConfig `config:",inline"`
Filters []filter.FilterConfig
Path paths.Path
Shipper publisher.ShipperConfig `config:",inline"`
Output map[string]*common.Config `config:"output"`
Logging logp.Logging `config:"logging"`
Filters []filter.FilterConfig `config:"filters"`
Path paths.Path `config:"path"`
}

// Run initializes and runs a Beater implementation. name is the name of the
Expand Down
10 changes: 5 additions & 5 deletions libbeat/publisher/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ type Publisher struct {

type ShipperConfig struct {
common.EventMetadata `config:",inline"` // Fields and tags to add to each event.
Name string
RefreshTopologyFreq time.Duration `config:"refresh_topology_freq"`
Ignore_outgoing bool `config:"ignore_outgoing"`
Topology_expire int `config:"topology_expire"`
Geoip common.Geoip `config:"geoip"`
Name string `config:"name"`
RefreshTopologyFreq time.Duration `config:"refresh_topology_freq"`
Ignore_outgoing bool `config:"ignore_outgoing"`
Topology_expire int `config:"topology_expire"`
Geoip common.Geoip `config:"geoip"`

// internal publisher queue sizes
QueueSize *int `config:"queue_size"`
Expand Down
7 changes: 6 additions & 1 deletion winlogbeat/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ type Settings struct {
// Validate validates the Settings data and returns an error describing
// all problems or nil if there are none.
func (s Settings) Validate() error {
validKeys := []string{"filters", "logging", "output", "shipper", "winlogbeat"}
validKeys := []string{
"fields", "fields_under_root", "tags",
"name", "refresh_topology_freq", "ignore_outgoing", "topology_expire", "geoip",
"queue_size", "bulk_queue_size", "max_procs",
"filters", "logging", "output", "path", "winlogbeat",
}
sort.Strings(validKeys)

// Check for invalid top-level keys.
Expand Down
5 changes: 3 additions & 2 deletions winlogbeat/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ func TestConfigValidate(t *testing.T) {
},
map[string]interface{}{"other": "value"},
},
"1 error: Invalid top-level key 'other' found. Valid keys are " +
"filters, logging, output, shipper, winlogbeat",
"1 error: Invalid top-level key 'other' found. Valid keys are bulk_queue_size, " +
"fields, fields_under_root, filters, geoip, ignore_outgoing, logging, max_procs, " +
"name, output, path, queue_size, refresh_topology_freq, tags, topology_expire, winlogbeat",
},
{
WinlogbeatConfig{},
Expand Down

0 comments on commit 845cd14

Please sign in to comment.