Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foundation for Logstash Metricbeat module #5540

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Add etcd module. {issue}4970[4970]
- Add ip address of docker containers to event. {pull}5379[5379]
- Add ceph osd tree infomation to metricbeat {pull}5498[5498]
- Add basic Logstash module. {pull}5540[5540]

*Packetbeat*

Expand Down
4 changes: 4 additions & 0 deletions metricbeat/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ services:
- ./module/kafka/_meta/env
- ./module/kibana/_meta/env
- ./module/kubernetes/_meta/env
- ./module/logstash/_meta/env
- ./module/memcached/_meta/env
- ./module/mongodb/_meta/env
- ./module/mysql/_meta/env
Expand Down Expand Up @@ -96,6 +97,9 @@ services:
depends_on:
- kubernetes

logstash:
build: ./module/logstash/_meta

memcached:
build: ./module/memcached/_meta

Expand Down
61 changes: 61 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ grouped in the following categories:
* <<exported-fields-kibana>>
* <<exported-fields-kubernetes-processor>>
* <<exported-fields-kubernetes>>
* <<exported-fields-logstash>>
* <<exported-fields-memcached>>
* <<exported-fields-mongodb>>
* <<exported-fields-mysql>>
Expand Down Expand Up @@ -6147,6 +6148,66 @@ type: long
Total inodes


[[exported-fields-logstash]]
== Logstash fields

experimental[]
Logstash module



[float]
== logstash fields




[float]
== node fields

node



[float]
=== `logstash.node.host`

type: keyword

Host name


[float]
=== `logstash.node.version`

type: keyword

Logstash Version


[float]
== jvm fields

JVM Info



[float]
=== `logstash.node.jvm.version`

type: keyword

Version


[float]
=== `logstash.node.jvm.pid`

type: long

Pid


[[exported-fields-memcached]]
== Memcached fields

Expand Down
37 changes: 37 additions & 0 deletions metricbeat/docs/modules/logstash.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-module-logstash]]
== logstash module

This is the logstash module.



[float]
=== Example configuration

The Logstash module supports the standard configuration options that are described
in <<configuration-metricbeat>>. Here is an example configuration:

[source,yaml]
----
metricbeat.modules:
- module: logstash
metricsets: ["node"]
enabled: false
period: 10s
hosts: ["localhost"]

----

[float]
=== Metricsets

The following metricsets are available:

* <<metricbeat-metricset-logstash-node,node>>

include::logstash/node.asciidoc[]

19 changes: 19 additions & 0 deletions metricbeat/docs/modules/logstash/node.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-metricset-logstash-node]]
include::../../../module/logstash/node/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-logstash,exported fields>> section.

Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/logstash/node/_meta/data.json[]
----
2 changes: 2 additions & 0 deletions metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This file is generated! See scripts/docs_collector.py
* <<metricbeat-module-kafka,Kafka>>
* <<metricbeat-module-kibana,Kibana>>
* <<metricbeat-module-kubernetes,Kubernetes>>
* <<metricbeat-module-logstash,Logstash>>
* <<metricbeat-module-memcached,Memcached>>
* <<metricbeat-module-mongodb,MongoDB>>
* <<metricbeat-module-mysql,MySQL>>
Expand Down Expand Up @@ -51,6 +52,7 @@ include::modules/jolokia.asciidoc[]
include::modules/kafka.asciidoc[]
include::modules/kibana.asciidoc[]
include::modules/kubernetes.asciidoc[]
include::modules/logstash.asciidoc[]
include::modules/memcached.asciidoc[]
include::modules/mongodb.asciidoc[]
include::modules/mysql.asciidoc[]
Expand Down
2 changes: 2 additions & 0 deletions metricbeat/include/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ import (
_ "github.com/elastic/beats/metricbeat/module/kubernetes/system"
_ "github.com/elastic/beats/metricbeat/module/kubernetes/util"
_ "github.com/elastic/beats/metricbeat/module/kubernetes/volume"
_ "github.com/elastic/beats/metricbeat/module/logstash"
_ "github.com/elastic/beats/metricbeat/module/logstash/node"
_ "github.com/elastic/beats/metricbeat/module/memcached"
_ "github.com/elastic/beats/metricbeat/module/memcached/stats"
_ "github.com/elastic/beats/metricbeat/module/mongodb"
Expand Down
8 changes: 8 additions & 0 deletions metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,14 @@ metricbeat.modules:
metricsets:
- event

#------------------------------ Logstash Module ------------------------------
- module: logstash
metricsets: ["node"]
enabled: false
period: 10s
hosts: ["localhost"]


#------------------------------ Memcached Module -----------------------------
- module: memcached
metricsets: ["stats"]
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/module/logstash/_meta/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM docker.elastic.co/logstash/logstash:6.0.0-rc2

ENV XPACK_MONITORING_ENABLED=FALSE
HEALTHCHECK --interval=1s --retries=90 CMD curl -f http://localhost:9600
6 changes: 6 additions & 0 deletions metricbeat/module/logstash/_meta/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- module: logstash
metricsets: ["node"]
enabled: false
period: 10s
hosts: ["localhost"]

4 changes: 4 additions & 0 deletions metricbeat/module/logstash/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
== logstash module

This is the logstash module.

2 changes: 2 additions & 0 deletions metricbeat/module/logstash/_meta/env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
LOGSTASH_HOST=logstash
LOGSTASH_PORT=9600
13 changes: 13 additions & 0 deletions metricbeat/module/logstash/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
- key: logstash
title: "Logstash"
description: >
experimental[]

Logstash module
fields:
- name: logstash
type: group
description: >
fields:


4 changes: 4 additions & 0 deletions metricbeat/module/logstash/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
Package logstash is a Metricbeat module that contains MetricSets.
*/
package logstash
23 changes: 23 additions & 0 deletions metricbeat/module/logstash/node/_meta/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"@timestamp": "2017-10-12T08:05:34.853Z",
"beat": {
"hostname": "host.example.com",
"name": "host.example.com"
},
"logstash": {
"node": {
"host": "9b61b9bdb06a",
"jvm": {
"pid": 1,
"version": "1.8.0_151"
},
"version": "6.0.0-rc2"
}
},
"metricset": {
"host": "127.0.0.1:9600",
"module": "logstash",
"name": "node",
"rtt": 115
}
}
3 changes: 3 additions & 0 deletions metricbeat/module/logstash/node/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
=== logstash node MetricSet

This is the node metricset of the module logstash.
26 changes: 26 additions & 0 deletions metricbeat/module/logstash/node/_meta/fields.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
- name: node
type: group
description: >
node
fields:
- name: host
type: keyword
description: >
Host name
- name: version
type: keyword
description: >
Logstash Version
- name: jvm
type: group
description: >
JVM Info
fields:
- name: version
type: keyword
description: >
Version
- name: pid
type: long
description: >
Pid
22 changes: 22 additions & 0 deletions metricbeat/module/logstash/node/data.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package node

import (
"github.com/elastic/beats/libbeat/common"
s "github.com/elastic/beats/libbeat/common/schema"
c "github.com/elastic/beats/libbeat/common/schema/mapstriface"
)

var (
schema = s.Schema{
"host": c.Str("host"),
"version": c.Str("version"),
"jvm": c.Dict("jvm", s.Schema{
"version": c.Str("version"),
"pid": c.Int("pid"),
}),
}
)

func eventMapping(node map[string]interface{}) (common.MapStr, *s.Errors) {
return schema.Apply(node)
}
51 changes: 51 additions & 0 deletions metricbeat/module/logstash/node/node.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package node

import (
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/metricbeat/helper"
"github.com/elastic/beats/metricbeat/mb"
"github.com/elastic/beats/metricbeat/mb/parse"
)

// init registers the MetricSet with the central registry.
// The New method will be called after the setup of the module and before starting to fetch data
func init() {
if err := mb.Registry.AddMetricSet("logstash", "node", New, hostParser); err != nil {
panic(err)
}
}

var (
hostParser = parse.URLHostParserBuilder{
DefaultScheme: "http",
PathConfigKey: "path",
DefaultPath: "_node",
}.Build()
)

// MetricSet type defines all fields of the MetricSet
type MetricSet struct {
mb.BaseMetricSet
http *helper.HTTP
}

// New create a new instance of the MetricSet
func New(base mb.BaseMetricSet) (mb.MetricSet, error) {
return &MetricSet{
base,
helper.NewHTTP(base),
}, nil
}

// Fetch methods implements the data gathering and data conversion to the right format
// 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.FetchJSON()
if err != nil {
return nil, err
}

event, _ := eventMapping(data)
return event, nil
}
Loading