Skip to content

Commit

Permalink
Add warnings stating Topbeat 'input' will be removed in 6.0. (elastic…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkroh authored and tsg committed Apr 14, 2016
1 parent 56a0296 commit 09eab61
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
22 changes: 14 additions & 8 deletions topbeat/beater/topbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ import (
"github.com/elastic/beats/topbeat/system"
)

const (
inputDeprecationWarning = "Using 'input' in configuration is deprecated " +
"and is scheduled to be removed in Topbeat 6.0."
)

type Topbeat struct {
period time.Duration

Expand Down Expand Up @@ -42,12 +47,13 @@ func (tb *Topbeat) Config(b *beat.Beat) error {
}

if tb.TbConfig.Topbeat != nil && tb.TbConfig.Input != nil {
return fmt.Errorf("topbeat and input are set in config. Only one can be enabled. input is deprecated, use topbeat.")
return fmt.Errorf("'topbeat' and 'input' are both set in config. Only " +
"one can be enabled so use 'topbeat'. " + inputDeprecationWarning)
}

// Copy input config to topbeat @deprecated
if tb.TbConfig.Input != nil {
logp.Warn("The 'input' configuration section is deprecated. Please use 'topbeat' instead")
logp.Warn(inputDeprecationWarning + " Use 'topbeat' instead.")
tb.TbConfig.Topbeat = tb.TbConfig.Input
}

Expand Down Expand Up @@ -90,12 +96,12 @@ func (tb *Topbeat) Config(b *beat.Beat) error {
}

logp.Debug("topbeat", "Init topbeat")
logp.Debug("topbeat", "Follow processes %q\n", tb.procStats.Procs)
logp.Debug("topbeat", "Period %v\n", tb.period)
logp.Debug("topbeat", "System statistics %t\n", tb.sysStats)
logp.Debug("topbeat", "Process statistics %t\n", tb.procStats.ProcStats)
logp.Debug("topbeat", "File system statistics %t\n", tb.fsStats)
logp.Debug("topbeat", "Cpu usage per core %t\n", tb.cpu.CpuPerCore)
logp.Debug("topbeat", "Follow processes %q", tb.procStats.Procs)
logp.Debug("topbeat", "Period %v", tb.period)
logp.Debug("topbeat", "System statistics %t", tb.sysStats)
logp.Debug("topbeat", "Process statistics %t", tb.procStats.ProcStats)
logp.Debug("topbeat", "File system statistics %t", tb.fsStats)
logp.Debug("topbeat", "Cpu usage per core %t", tb.cpu.CpuPerCore)

return nil
}
Expand Down
8 changes: 5 additions & 3 deletions topbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def test_invalid_config(self):
exit_code = self.run_beat(config="invalid.yml", extra_args=["-N"])

assert exit_code == 1
assert self.log_contains("topbeat and input are set in config") is True
assert self.log_contains(
"'topbeat' and 'input' are both set in config.") is True

def test_old_config(self):
"""
Expand All @@ -33,5 +34,6 @@ def test_old_config(self):
time.sleep(1)
topbeat.check_kill_and_wait()

assert self.log_contains("The 'input' configuration section is deprecated. Please use 'topbeat' instead") is True

assert self.log_contains(
"Using 'input' in configuration is deprecated and is scheduled to "
"be removed in Topbeat 6.0. Use 'topbeat' instead.") is True

0 comments on commit 09eab61

Please sign in to comment.