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

Index metricset for elasticsearch Metricbeat module #6881

Merged
merged 4 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -196,6 +196,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di
- Add accumulated I/O stats to diskio in the line of `docker stats`. {pull}6701[6701]
- Ignore virtual filesystem types by default in system module. {pull}6819[6819]
- Release config reloading feature as GA.
- Add experimental Elasticsearch index metricset.

*Packetbeat*

Expand Down
4 changes: 4 additions & 0 deletions metricbeat/_meta/fields.common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@
description: >
The document type. Always set to "doc".

- name: service.name
example: elasticsearch
description: >
Name of the service metricbeat fetches the data from.
92 changes: 92 additions & 0 deletions metricbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -1861,6 +1861,16 @@ required: True
The document type. Always set to "doc".


--

*`service.name`*::
+
--
example: elasticsearch

Name of the service metricbeat fetches the data from.


--

[[exported-fields-couchbase]]
Expand Down Expand Up @@ -3294,6 +3304,88 @@ type: keyword
Elasticsearch cluster name.


--

*`elasticsearch.cluster.id`*::
+
--
type: keyword

Elasticsearch cluster id.


--

[float]
== index fields

index



*`elasticsearch.index.name`*::
+
--
type: keyword

Index name.


--


*`elasticsearch.index.total.docs.count`*::
+
--
type: long

Total number of documents in the index.


--

*`elasticsearch.index.total.docs.deleted`*::
+
--
type: long

Total number of deleted documents in the index.


--

*`elasticsearch.index.total.store.size.bytes`*::
+
--
type: long

format: bytes

Total size of the index in bytes.


--

*`elasticsearch.index.total.segments.count`*::
+
--
type: long

Total number of index segments.


--

*`elasticsearch.index.total.segments.memory.bytes`*::
+
--
type: long

format: bytes

Total number of memory used by the segments in bytes.


--

[float]
Expand Down
9 changes: 8 additions & 1 deletion metricbeat/docs/modules/elasticsearch.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ in <<configuration-metricbeat>>. Here is an example configuration:
----
metricbeat.modules:
- module: elasticsearch
metricsets: ["node", "node_stats"]
metricsets:
#- index
- node
- node_stats
period: 10s
hosts: ["localhost:9200"]
----
Expand All @@ -34,10 +37,14 @@ This module supports TLS connection when using `ssl` config field, as described

The following metricsets are available:

* <<metricbeat-metricset-elasticsearch-index,index>>

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

* <<metricbeat-metricset-elasticsearch-node_stats,node_stats>>

include::elasticsearch/index.asciidoc[]

include::elasticsearch/node.asciidoc[]

include::elasticsearch/node_stats.asciidoc[]
Expand Down
23 changes: 23 additions & 0 deletions metricbeat/docs/modules/elasticsearch/index.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
////
This file is generated! See scripts/docs_collector.py
////

[[metricbeat-metricset-elasticsearch-index]]
=== Elasticsearch index metricset

experimental[]

include::../../../module/elasticsearch/index/_meta/docs.asciidoc[]


==== Fields

For a description of each field in the metricset, see the
<<exported-fields-elasticsearch,exported fields>> section.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ID doesn't to exist exported-fields-elasticsearch?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@exekias I really think the error here is related to how our tests are written, not the doc source. I tested the files offline and they build without errors. I think it's safe to ignore the error messages here.


Here is an example document generated by this metricset:

[source,json]
----
include::../../../module/elasticsearch/index/_meta/data.json[]
----
3 changes: 2 additions & 1 deletion metricbeat/docs/modules_list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ This file is generated! See scripts/docs_collector.py
|<<metricbeat-module-dropwizard,Dropwizard>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
.1+| .1+| |<<metricbeat-metricset-dropwizard-collector,collector>> beta[]
|<<metricbeat-module-elasticsearch,Elasticsearch>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
.2+| .2+| |<<metricbeat-metricset-elasticsearch-node,node>> beta[]
.3+| .3+| |<<metricbeat-metricset-elasticsearch-index,index>> experimental[]
|<<metricbeat-metricset-elasticsearch-node,node>> beta[]
|<<metricbeat-metricset-elasticsearch-node_stats,node_stats>> beta[]
|<<metricbeat-module-etcd,Etcd>> beta[] |image:./images/icon-no.png[No prebuilt dashboards] |
.3+| .3+| |<<metricbeat-metricset-etcd-leader,leader>> beta[]
Expand Down
1 change: 1 addition & 0 deletions metricbeat/include/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import (
_ "github.com/elastic/beats/metricbeat/module/dropwizard"
_ "github.com/elastic/beats/metricbeat/module/dropwizard/collector"
_ "github.com/elastic/beats/metricbeat/module/elasticsearch"
_ "github.com/elastic/beats/metricbeat/module/elasticsearch/index"
_ "github.com/elastic/beats/metricbeat/module/elasticsearch/node"
_ "github.com/elastic/beats/metricbeat/module/elasticsearch/node_stats"
_ "github.com/elastic/beats/metricbeat/module/etcd"
Expand Down
22 changes: 22 additions & 0 deletions metricbeat/mb/testing/data_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,28 @@ func WriteEvents(f mb.EventsFetcher, t testing.TB) error {
return nil
}

// WriteEventsReporterV2 fetches events and writes the first event to a ./_meta/data.json
// file.
func WriteEventsReporterV2(f mb.ReportingMetricSetV2, t testing.TB) error {
if !*dataFlag {
t.Skip("skip data generation tests")
}

events, errs := ReportingFetchV2(f)
if len(errs) > 0 {
return errs[0]
}

if len(events) == 0 {
return fmt.Errorf("no events were generated")
}

e := StandardizeEvent(f, events[0])

WriteEventToDataJSON(t, e)
return nil
}

// CreateFullEvent builds a full event given the data generated by a MetricSet.
// This simulates the output of Metricbeat as if it were
// 2016-05-23T08:05:34.853Z and the hostname is host.example.com.
Expand Down
21 changes: 17 additions & 4 deletions metricbeat/mb/testing/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,25 +151,38 @@ func NewReportingMetricSetV2(t testing.TB, config interface{}) mb.ReportingMetri
return reportingMetricSetV2
}

type capturingReporterV2 struct {
// CapturingReporterV2 is a reporter used for testing which stores all events and errors
type CapturingReporterV2 struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type CapturingReporterV2 should have comment or be unexported

events []mb.Event
errs []error
}

func (r *capturingReporterV2) Event(event mb.Event) bool {
// Event is used to report an event
func (r *CapturingReporterV2) Event(event mb.Event) bool {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method CapturingReporterV2.Event should have comment or be unexported

r.events = append(r.events, event)
return true
}

func (r *capturingReporterV2) Error(err error) bool {
// Error is used to report an error
func (r *CapturingReporterV2) Error(err error) bool {
r.errs = append(r.errs, err)
return true
}

// GetEvents returns all reported events
func (r *CapturingReporterV2) GetEvents() []mb.Event {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method CapturingReporterV2.GetEvents should have comment or be unexported

return r.events
}

// GetErrors returns all reported errors
func (r *CapturingReporterV2) GetErrors() []error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported method CapturingReporterV2.GetErrors should have comment or be unexported

return r.errs
}

// ReportingFetchV2 runs the given reporting metricset and returns all of the
// events and errors that occur during that period.
func ReportingFetchV2(metricSet mb.ReportingMetricSetV2) ([]mb.Event, []error) {
r := &capturingReporterV2{}
r := &CapturingReporterV2{}
metricSet.Fetch(r)
return r.events, r.errs
}
Expand Down
5 changes: 4 additions & 1 deletion metricbeat/metricbeat.reference.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,10 @@ metricbeat.modules:

#---------------------------- Elasticsearch Module ---------------------------
- module: elasticsearch
metricsets: ["node", "node_stats"]
metricsets:
#- index
- node
- node_stats
period: 10s
hosts: ["localhost:9200"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
- module: elasticsearch
metricsets: ["node", "node_stats"]
metricsets:
#- index
- node
- node_stats
period: 10s
hosts: ["localhost:9200"]
5 changes: 5 additions & 0 deletions metricbeat/module/elasticsearch/_meta/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
type: keyword
description: >
Elasticsearch cluster name.

- name: cluster.id
type: keyword
description: >
Elasticsearch cluster id.
Loading