From 0e4f93842d32efb2483485e0f5f49dc2d8073369 Mon Sep 17 00:00:00 2001 From: Nicolas Ruflin Date: Fri, 1 Feb 2019 08:56:47 +0100 Subject: [PATCH] [Metricbeat] Release munin as GA. (#10311) Add integration tests and add data.json file. --- CHANGELOG.next.asciidoc | 1 + metricbeat/docs/modules/munin.asciidoc | 2 - metricbeat/docs/modules/munin/node.asciidoc | 8 +- metricbeat/docs/modules_list.asciidoc | 4 +- metricbeat/module/munin/_meta/fields.yml | 2 +- metricbeat/module/munin/fields.go | 2 +- metricbeat/module/munin/node/_meta/data.json | 35 ++++++++ metricbeat/module/munin/node/_meta/fields.yml | 2 +- metricbeat/module/munin/node/node.go | 2 - .../munin/node/node_integration_test.go | 88 +++++++++++++++++++ 10 files changed, 135 insertions(+), 11 deletions(-) create mode 100644 metricbeat/module/munin/node/_meta/data.json create mode 100644 metricbeat/module/munin/node/node_integration_test.go diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 96840f5c9ff..26bd7efceac 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -269,6 +269,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d - Release kvm module as beta. {pull}10279[10279] - Release http.server metricset as GA. {pull}10240[10240] - Release Nats module as GA. {pull}10281[10281] +- Release munin module as GA. {pull}10311[10311] - Release use of xpack.enabled: true flag in Elasticsearch and Kibana modules as GA. {pull}10222[10222] - Add support for MySQL 8.0 and tests also for Percona and MariaDB. {pull}10261[10261] - Rename 'db' Metricset to 'transaction_log' in MSSQL Metricbeat module {pull}10109[10109] diff --git a/metricbeat/docs/modules/munin.asciidoc b/metricbeat/docs/modules/munin.asciidoc index c0b5bb8460a..19d2fb1a2c1 100644 --- a/metricbeat/docs/modules/munin.asciidoc +++ b/metricbeat/docs/modules/munin.asciidoc @@ -5,8 +5,6 @@ This file is generated! See scripts/docs_collector.py [[metricbeat-module-munin]] == Munin module -beta[] - This is the munin module. The default metricset is `node`. diff --git a/metricbeat/docs/modules/munin/node.asciidoc b/metricbeat/docs/modules/munin/node.asciidoc index a485a6a730e..d995cc42f37 100644 --- a/metricbeat/docs/modules/munin/node.asciidoc +++ b/metricbeat/docs/modules/munin/node.asciidoc @@ -5,8 +5,6 @@ This file is generated! See scripts/docs_collector.py [[metricbeat-metricset-munin-node]] === Munin node metricset -beta[] - include::../../../module/munin/node/_meta/docs.asciidoc[] @@ -15,3 +13,9 @@ include::../../../module/munin/node/_meta/docs.asciidoc[] For a description of each field in the metricset, see the <> section. +Here is an example document generated by this metricset: + +[source,json] +---- +include::../../../module/munin/node/_meta/data.json[] +---- diff --git a/metricbeat/docs/modules_list.asciidoc b/metricbeat/docs/modules_list.asciidoc index b08a39c0b24..69984a9da13 100644 --- a/metricbeat/docs/modules_list.asciidoc +++ b/metricbeat/docs/modules_list.asciidoc @@ -103,8 +103,8 @@ This file is generated! See scripts/docs_collector.py |<> beta[] |image:./images/icon-yes.png[Prebuilt dashboards are available] | .2+| .2+| |<> experimental[] |<> experimental[] -|<> beta[] |image:./images/icon-no.png[No prebuilt dashboards] | -.1+| .1+| |<> beta[] +|<> |image:./images/icon-no.png[No prebuilt dashboards] | +.1+| .1+| |<> |<> |image:./images/icon-yes.png[Prebuilt dashboards are available] | .2+| .2+| |<> beta[] |<> diff --git a/metricbeat/module/munin/_meta/fields.yml b/metricbeat/module/munin/_meta/fields.yml index d36f9fd50bd..1516f1c775f 100644 --- a/metricbeat/module/munin/_meta/fields.yml +++ b/metricbeat/module/munin/_meta/fields.yml @@ -2,7 +2,7 @@ title: "Munin" description: > Munin node metrics exporter - release: beta + release: ga fields: - name: munin.metrics.* type: object diff --git a/metricbeat/module/munin/fields.go b/metricbeat/module/munin/fields.go index bb04054e8b3..3d879b85f9e 100644 --- a/metricbeat/module/munin/fields.go +++ b/metricbeat/module/munin/fields.go @@ -32,5 +32,5 @@ func init() { // AssetMunin returns asset data. // This is the base64 encoded gzipped contents of ../metricbeat/module/munin. func AssetMunin() string { - return "eJx8kU1qwzAUhPc+xZBNIBAfQIveoL1CkK2Jq0Z/SM+0vn2xpZaYmi7fzBvm09MVDy4Kfg42dIBYcVQ4va7zqQMMy5htEhuDwksHAJuHEA3hKdmOBfxKMQtzB2Q66kKFgaI74G7pTFFb8oqgPVtb38L9ZfMAWRIV4vDBUZpUh1t1TJwHx7/OzeuUbJja2vlybjsH7Bv/E3ShwbBAI7l5sgHxDl3x6gP1xCD9AXzd71dph//g8hmz+Z/gTXuuVfLOn+IxOsdRbJhWtfye9qB71zflOKemPJ+6pvaf8R0AAP//7IiXDQ==" + return "eJx8kUFuwyAURPc+xSibSJHiA7DoDdorRNhMKA0GBN9qffvKhlaOanX5Z/5oHp8rHlwUpjm40AHixFPh9LrOpw4wLGN2SVwMCi8dAGweQjTERMluLOBXilmYOyDTUxcqWN0Bd0dvitpyVwQ9sXX1LdpfNg+QJVEhDh8cpUl1uFXHxHnw/OvcJp2SC7atnS/ntnNAvtHvkAsNhgUayc/WBcQ7dMWrz9OWQfoD+Lrfr9IT/oPLZ8zmf4I3PXGtknf+FI/Re47igl3V8nvYg+6nPpvjnJqyP3VN7b/iOwAA//84wJVl" } diff --git a/metricbeat/module/munin/node/_meta/data.json b/metricbeat/module/munin/node/_meta/data.json new file mode 100644 index 00000000000..790c54a5f3b --- /dev/null +++ b/metricbeat/module/munin/node/_meta/data.json @@ -0,0 +1,35 @@ +{ + "@timestamp": "2017-10-12T08:05:34.853Z", + "agent": { + "hostname": "host.example.com", + "name": "host.example.com" + }, + "event": { + "dataset": "munin.node", + "duration": 115000, + "module": "munin" + }, + "metricset": { + "name": "node" + }, + "munin": { + "metrics": { + "guest": 0, + "idle": 6999219, + "iowait": 5441, + "irq": 0, + "nice": 0, + "softirq": 6419, + "steal": 0, + "system": 374903, + "user": 486780 + }, + "plugin": { + "name": "cpu" + } + }, + "service": { + "address": "127.0.0.1:4949", + "type": "cpu" + } +} \ No newline at end of file diff --git a/metricbeat/module/munin/node/_meta/fields.yml b/metricbeat/module/munin/node/_meta/fields.yml index 8033a27f5ac..a927f3fc9f8 100644 --- a/metricbeat/module/munin/node/_meta/fields.yml +++ b/metricbeat/module/munin/node/_meta/fields.yml @@ -1 +1 @@ -- release: beta +- release: ga diff --git a/metricbeat/module/munin/node/node.go b/metricbeat/module/munin/node/node.go index 604d7553fb0..7bc9cde2342 100644 --- a/metricbeat/module/munin/node/node.go +++ b/metricbeat/module/munin/node/node.go @@ -21,7 +21,6 @@ import ( "time" "github.com/elastic/beats/libbeat/common" - "github.com/elastic/beats/libbeat/common/cfgwarn" "github.com/elastic/beats/libbeat/logp" "github.com/elastic/beats/metricbeat/mb" "github.com/elastic/beats/metricbeat/module/munin" @@ -52,7 +51,6 @@ type MetricSet struct { // New creates a new instance of the MetricSet. New is responsible for unpacking // any MetricSet specific configuration options if there are any. func New(base mb.BaseMetricSet) (mb.MetricSet, error) { - cfgwarn.Beta("The munin node metricset is beta.") config := defaultConfig if err := base.Module().UnpackConfig(&config); err != nil { diff --git a/metricbeat/module/munin/node/node_integration_test.go b/metricbeat/module/munin/node/node_integration_test.go new file mode 100644 index 00000000000..1e8fbbe2fd6 --- /dev/null +++ b/metricbeat/module/munin/node/node_integration_test.go @@ -0,0 +1,88 @@ +// Licensed to Elasticsearch B.V. under one or more contributor +// license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright +// ownership. Elasticsearch B.V. licenses this file to you under +// the Apache License, Version 2.0 (the "License"); you may +// not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +// +build integration + +package node + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/elastic/beats/libbeat/tests/compose" + mbtest "github.com/elastic/beats/metricbeat/mb/testing" +) + +func TestFetch(t *testing.T) { + compose.EnsureUp(t, "munin") + + f := mbtest.NewReportingMetricSetV2(t, getConfig()) + events, errs := mbtest.ReportingFetchV2(f) + + assert.Empty(t, errs) + if !assert.NotEmpty(t, events) { + t.FailNow() + } + + t.Logf("%s/%s event: %+v", f.Module().Name(), f.Name(), + events[0].BeatEvent("munin", "node").Fields.StringToPrint()) +} + +func TestData(t *testing.T) { + compose.EnsureUp(t, "munin") + + config := getConfig() + f := mbtest.NewReportingMetricSetV2(t, config) + err := mbtest.WriteEventsReporterV2(f, t, ".") + if err != nil { + t.Fatal("write", err) + } +} + +func getConfig() map[string]interface{} { + return map[string]interface{}{ + "module": "munin", + "metricsets": []string{"node"}, + "hosts": []string{GetEnvHost() + ":" + GetEnvPort()}, + } +} + +// GetEnvHost returns the hostname of the Mongodb server to use for testing. +// It reads the value from the MONGODB_HOST environment variable and returns +// 127.0.0.1 if it is not set. +func GetEnvHost() string { + host := os.Getenv("MUNIN_HOST") + + if len(host) == 0 { + host = "127.0.0.1" + } + return host +} + +// GetEnvPort returns the port of the Mongodb server to use for testing. +// It reads the value from the MONGODB_PORT environment variable and returns +// 27017 if it is not set. +func GetEnvPort() string { + port := os.Getenv("MUNIN_PORT") + + if len(port) == 0 { + port = "4949" + } + return port +}