Skip to content

Commit

Permalink
[Metricbeat] Release munin as GA. (#10311)
Browse files Browse the repository at this point in the history
Add integration tests and add data.json file.
  • Loading branch information
ruflin authored Feb 1, 2019
1 parent 98e38be commit 0e4f938
Show file tree
Hide file tree
Showing 10 changed files with 135 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 0 additions & 2 deletions metricbeat/docs/modules/munin.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
8 changes: 6 additions & 2 deletions metricbeat/docs/modules/munin/node.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]


Expand All @@ -15,3 +13,9 @@ include::../../../module/munin/node/_meta/docs.asciidoc[]
For a description of each field in the metricset, see the
<<exported-fields-munin,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/munin/node/_meta/data.json[]
----
4 changes: 2 additions & 2 deletions metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ This file is generated! See scripts/docs_collector.py
|<<metricbeat-module-mssql,mssql>> beta[] |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.2+| .2+| |<<metricbeat-metricset-mssql-performance,performance>> experimental[]
|<<metricbeat-metricset-mssql-transaction_log,transaction_log>> experimental[]
|<<metricbeat-module-munin,Munin>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
.1+| .1+| |<<metricbeat-metricset-munin-node,node>> beta[]
|<<metricbeat-module-munin,Munin>> |image:./images/icon-no.png[No prebuilt dashboards] |
.1+| .1+| |<<metricbeat-metricset-munin-node,node>>
|<<metricbeat-module-mysql,MySQL>> |image:./images/icon-yes.png[Prebuilt dashboards are available] |
.2+| .2+| |<<metricbeat-metricset-mysql-galera_status,galera_status>> beta[]
|<<metricbeat-metricset-mysql-status,status>>
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/munin/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Munin"
description: >
Munin node metrics exporter
release: beta
release: ga
fields:
- name: munin.metrics.*
type: object
Expand Down
2 changes: 1 addition & 1 deletion metricbeat/module/munin/fields.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions metricbeat/module/munin/node/_meta/data.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
2 changes: 1 addition & 1 deletion metricbeat/module/munin/node/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- release: beta
- release: ga
2 changes: 0 additions & 2 deletions metricbeat/module/munin/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
88 changes: 88 additions & 0 deletions metricbeat/module/munin/node/node_integration_test.go
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit 0e4f938

Please sign in to comment.