Skip to content

Commit

Permalink
Use logp.Beta or logp.Experimental in metricsets
Browse files Browse the repository at this point in the history
And in system tests, centralize the logic for asserting that there are no ERR or WARN in logs.

Filter out errors about “The service process could not connect to the service controller” that occur when testing on Jenkins where Jenkins itself is running as a service. This confuses the Beat because it thinks that it is running as service, but it’s not.
  • Loading branch information
andrewkroh committed May 8, 2017
1 parent e86d38b commit 077d508
Show file tree
Hide file tree
Showing 50 changed files with 85 additions and 183 deletions.
3 changes: 1 addition & 2 deletions metricbeat/module/ceph/cluster_disk/cluster_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The ceph cluster_disk metricset is experimental")
logp.Experimental("The ceph cluster_disk metricset is experimental")

http := helper.NewHTTP(base)
http.SetHeader("Accept", "application/json")
Expand All @@ -44,7 +44,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
}

func (m *MetricSet) Fetch() (common.MapStr, error) {

content, err := m.HTTP.FetchContent()

if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/module/ceph/cluster_health/cluster_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The ceph cluster_health metricset is beta")
logp.Beta("The ceph cluster_health metricset is beta")

http := helper.NewHTTP(base)
http.SetHeader("Accept", "application/json")
Expand All @@ -44,7 +44,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
}

func (m *MetricSet) Fetch() (common.MapStr, error) {

content, err := m.HTTP.FetchContent()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/ceph/monitor_health/monitor_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The ceph monitor_health metricset is beta")
logp.Beta("The ceph monitor_health metricset is beta")

http := helper.NewHTTP(base)
http.SetHeader("Accept", "application/json")
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/module/ceph/pool_disk/pool_disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The ceph pool_disk metricset is experimental")
logp.Experimental("The ceph pool_disk metricset is experimental")

http := helper.NewHTTP(base)
http.SetHeader("Accept", "application/json")
Expand All @@ -44,7 +44,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {

content, err := m.HTTP.FetchContent()

if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/couchbase/bucket/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type MetricSet struct {

// New create a new instance of the MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The couchbase bucket metricset is beta")
logp.Beta("The couchbase bucket metricset is beta")

return &MetricSet{
BaseMetricSet: base,
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/couchbase/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type MetricSet struct {

// New create a new instance of the MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The couchbase cluster metricset is beta")
logp.Beta("The couchbase cluster metricset is beta")

return &MetricSet{
BaseMetricSet: base,
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/couchbase/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type MetricSet struct {

// New create a new instance of the MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The couchbase node metricset is beta")
logp.Beta("The couchbase node metricset is beta")

return &MetricSet{
BaseMetricSet: base,
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/container/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type MetricSet struct {

// New creates a new instance of the docker container MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The docker container metricset is beta")
logp.Beta("The docker container metricset is beta")

config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type MetricSet struct {

// New creates a new instance of the docker cpu MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The docker cpu metricset is beta")
logp.Beta("The docker cpu metricset is beta")

config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/diskio/diskio.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type MetricSet struct {

// New create a new instance of the docker diskio MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The docker diskio metricset is beta")
logp.Beta("The docker diskio metricset is beta")

config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/healthcheck/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type MetricSet struct {

// New creates a new instance of the docker healthcheck MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The docker healthcheck metricset is beta")
logp.Beta("The docker healthcheck metricset is beta")

config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions metricbeat/module/docker/image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ type MetricSet struct {
// Part of new is also setting up the configuration by processing additional
// configuration entries if needed.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

logp.Warn("BETA: The docker info metricset is beta")
logp.Beta("The docker info metricset is beta")

config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
Expand All @@ -53,7 +52,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// It returns the event which is then forward to the output. In case of an error, a
// descriptive error must be returned.
func (m *MetricSet) Fetch() ([]common.MapStr, error) {

images, err := m.dockerClient.ListImages(dc.ListImagesOptions{})
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type MetricSet struct {

// New create a new instance of the docker info MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The docker info metricset is beta")
logp.Beta("The docker info metricset is beta")

config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/memory/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type MetricSet struct {

// New creates a new instance of the docker memory MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The docker memory metricset is beta")
logp.Beta("The docker memory metricset is beta")

config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/docker/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type MetricSet struct {

// New creates a new instance of the docker network MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The docker network metricset is beta")
logp.Beta("The docker network metricset is beta")

config := docker.Config{}
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions metricbeat/module/golang/expvar/expvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ type MetricSet struct {
// Part of new is also setting up the configuration by processing additional
// configuration entries if needed.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

logp.Warn("EXPERIMENTAL: The golang expvar metricset is experimental")
logp.Experimental("The golang expvar metricset is experimental")

config := struct {
Namespace string `config:"expvar.namespace" validate:"required"`
Expand All @@ -66,7 +65,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// It returns the event which is then forward to the output. In case of an error, a
// descriptive error must be returned.
func (m *MetricSet) Fetch() (common.MapStr, error) {

json, err := m.http.FetchJSON()

if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions metricbeat/module/golang/heap/heap.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ type MetricSet struct {
// Part of new is also setting up the configuration by processing additional
// configuration entries if needed.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

logp.Warn("EXPERIMENTAL: The golang heap metricset is experimental")
logp.Experimental("The golang heap metricset is experimental")

return &MetricSet{
BaseMetricSet: base,
Expand All @@ -60,7 +59,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
// It returns the event which is then forward to the output. In case of an error, a
// descriptive error must be returned.
func (m *MetricSet) Fetch() (common.MapStr, error) {

data, err := m.http.FetchContent()
if err != nil {
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/module/http/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ type MetricSet struct {
// Part of new is also setting up the configuration by processing additional
// configuration entries if needed.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

logp.Warn("The http json metricset is in beta.")
logp.Beta("The http json metricset is in beta.")

config := struct {
Namespace string `config:"namespace" validate:"required"`
Expand Down
3 changes: 1 addition & 2 deletions metricbeat/module/jolokia/jmx/jmx.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type MetricSet struct {

// New create a new instance of the MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The jolokia jmx metricset is beta")
logp.Beta("The jolokia jmx metricset is beta")

// Additional configuration options
config := struct {
Expand Down Expand Up @@ -78,7 +78,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

// Fetch methods implements the data gathering and data conversion to the right format
func (m *MetricSet) Fetch() (common.MapStr, error) {

body, err := m.http.FetchContent()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/consumergroup/consumergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var debugf = logp.MakeDebug("kafka")

// New creates a new instance of the MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The kafka consumergroup metricset is beta")
logp.Beta("The kafka consumergroup metricset is beta")

config := defaultConfig
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/kafka/partition/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var debugf = logp.MakeDebug("kafka")

// New creates a new instance of the partition MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The kafka partition metricset is beta")
logp.Beta("The kafka partition metricset is beta")

config := defaultConfig
if err := base.Module().UnpackConfig(&config); err != nil {
Expand Down
4 changes: 1 addition & 3 deletions metricbeat/module/memcached/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

logp.Warn("BETA: The memcached stats metricset is beta")
logp.Beta("The memcached stats metricset is beta")

return &MetricSet{
BaseMetricSet: base,
}, nil
}

func (m *MetricSet) Fetch() (common.MapStr, error) {

conn, err := net.DialTimeout("tcp", m.Host(), m.Module().Config().Timeout)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/mongodb/dbstats/dbstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type MetricSet struct {
// Part of new is also setting up the configuration by processing additional
// configuration entries if needed.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The %v %v metricset is experimental", base.Module().Name(), base.Name())
logp.Experimental("The %v %v metricset is experimental", base.Module().Name(), base.Name())

dialInfo, err := mgo.ParseURL(base.HostData().URI)
if err != nil {
Expand Down
3 changes: 2 additions & 1 deletion metricbeat/module/php_fpm/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ type MetricSet struct {

// New create a new instance of the MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The php-fpm pool metricset is beta")
logp.Beta("The php_fpm pool metricset is beta")

return &MetricSet{
base,
helper.NewHTTP(base),
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/prometheus/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The prometheus collector metricset is beta")
logp.Beta("The prometheus collector metricset is beta")

config := struct {
Namespace string `config:"namespace" validate:"required"`
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/prometheus/stats/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The prometheus stats metricset is beta")
logp.Beta("The prometheus stats metricset is beta")

return &MetricSet{
BaseMetricSet: base,
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/vsphere/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("EXPERIMENTAL: The vsphere datastore metricset is experimental")
logp.Experimental("The vsphere datastore metricset is experimental")

config := struct {
Username string `config:"username"`
Expand Down
4 changes: 1 addition & 3 deletions metricbeat/module/vsphere/host/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

logp.Warn("EXPERIMENTAL: The vsphere host metricset is experimental")
logp.Experimental("The vsphere host metricset is experimental")

config := struct {
Username string `config:"username"`
Expand Down Expand Up @@ -61,7 +60,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {

f := find.NewFinder(m.Client, true)
if f == nil {
return nil, errors.New("Finder undefined for vsphere.")
Expand Down
4 changes: 1 addition & 3 deletions metricbeat/module/vsphere/virtualmachine/virtualmachine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ type MetricSet struct {
}

func New(base mb.BaseMetricSet) (mb.MetricSet, error) {

logp.Warn("EXPERIMENTAL: The vsphere virtualmachine metricset is experimental")
logp.Experimental("The vsphere virtualmachine metricset is experimental")

config := struct {
Username string `config:"username"`
Expand Down Expand Up @@ -62,7 +61,6 @@ func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
}

func (m *MetricSet) Fetch() ([]common.MapStr, error) {

f := find.NewFinder(m.Client, true)
if f == nil {
return nil, errors.New("Finder undefined for vsphere.")
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/windows/perfmon/perfmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type MetricSet struct {

// New create a new instance of the MetricSet.
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
logp.Warn("BETA: The perfmon metricset is beta")
logp.Beta("The perfmon metricset is beta")

config := struct {
CounterConfig []CounterConfig `config:"perfmon.counters" validate:"required"`
Expand Down
12 changes: 12 additions & 0 deletions metricbeat/tests/system/metricbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,15 @@ def de_dot(self, existing_fields):
fields[key] = self.de_dot(fields[key])

return fields

def assert_no_logged_warnings(self):
"""
Assert that the log file contains no ERR or WARN lines.
"""
log = self.get_log()
log = log.replace("WARN EXPERIMENTAL", "")
log = log.replace("WARN BETA", "")
# Jenkins runs as a Windows service and when Jenkins executes theses
# tests the Beat is confused since it thinks it is running as a service.
log = log.replace("ERR Error: The service process could not connect to the service controller.", "")
self.assertNotRegexpMatches(log, "ERR|WARN")
5 changes: 1 addition & 4 deletions metricbeat/tests/system/test_apache.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ def test_output(self):
proc = self.start_beat()
self.wait_until(lambda: self.output_lines() > 0)
proc.check_kill_and_wait()

# Ensure no errors or warnings exist in the log.
log = self.get_log()
self.assertNotRegexpMatches(log, "ERR|WARN")
self.assert_no_logged_warnings()

output = self.read_output_json()
self.assertEqual(len(output), 1)
Expand Down
5 changes: 1 addition & 4 deletions metricbeat/tests/system/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ def test_start_stop(self):
proc = self.start_beat()
self.wait_until(lambda: self.log_contains("start running"))
proc.check_kill_and_wait()

# Ensure no errors or warnings exist in the log.
log = self.get_log()
self.assertNotRegexpMatches(log, "ERR|WARN")
self.assert_no_logged_warnings()

# Ensure all Beater stages are used.
assert self.log_contains("Setup Beat: metricbeat")
Expand Down
Loading

0 comments on commit 077d508

Please sign in to comment.