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

Conversation

ruflin
Copy link
Member

@ruflin ruflin commented Apr 17, 2018

This adds the index metricset to the Elasticsearch module. For now it only contains very basic metrics and is marked experimental.

This PR is used to create the basic for adding tests with the fetch reporter v2 interface and also generate data with it.

It also adds basic utility functions to fetch Master or Node information in the Elasticsearch module.

@ruflin ruflin added in progress Pull request is currently in progress. module review Metricbeat Metricbeat labels Apr 17, 2018
return clusterStruct.MasterNode, nil
}

func GetInfo(http *helper.HTTP, uri string) (*Info, error) {

Choose a reason for hiding this comment

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

exported function GetInfo should have comment or be unexported

func GetClusterID(http *helper.HTTP, uri string, nodeID string) (string, error) {

// Check if cluster id already cached. If yes, return it.
if clusterId, ok := clusterIDCache[nodeID]; ok {

Choose a reason for hiding this comment

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

var clusterId should be clusterID

// Global clusterIdCache. Assumption is that the same node id never can belong to a different cluster id
var clusterIDCache = map[string]string{}

type Info struct {

Choose a reason for hiding this comment

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

exported type Info should have comment or be unexported

return r.events
}

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

r.errs = append(r.errs, err)
return true
}

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

events []mb.Event
errs []error
}

func (r *capturingReporterV2) Event(event mb.Event) bool {
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

@@ -151,25 +151,33 @@ func NewReportingMetricSetV2(t testing.TB, config interface{}) mb.ReportingMetri
return reportingMetricSetV2
}

type capturingReporterV2 struct {
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

@@ -57,6 +57,28 @@ func WriteEvents(f mb.EventsFetcher, t testing.TB) error {
return nil
}

// WriteEvents fetches events and writes the first event to a ./_meta/data.json

Choose a reason for hiding this comment

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

comment on exported function WriteEventsReporterV2 should be of the form "WriteEventsReporterV2 ..."

Copy link
Contributor

@exekias exekias left a comment

Choose a reason for hiding this comment

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

This is a great addition to the module, I left some minor comments/questions

metricsets:
#- "index"
- "node"
- "node_stats"
Copy link
Contributor

Choose a reason for hiding this comment

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

you can drop " chars here

Copy link
Member Author

Choose a reason for hiding this comment

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

done

}

func eventMapping(node map[string]interface{}) common.MapStr {
event, _ := schema.Apply(node)
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps we want to stop/warn on error here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The error handling is partially broken here. We skip it in all the other modules too. We should revisit how we do error handling during parsing events.

}

func getNodeName(http *helper.HTTP, uri string) (string, error) {

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few methods with a starting empty line, it would be nice to remove them

Copy link
Member Author

Choose a reason for hiding this comment

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

removed all of them.

}

// Not master, no event sent
if !isMaster {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder what will be the behavior when monitoring from outside the cluster? for instance a cluster in Elastic Cloud

Copy link
Member Author

Choose a reason for hiding this comment

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

This will not work properly at the moment. We will have to introduce additional config options for this. See also discussion here: #6807 (comment)

I'm thinking that these will potentially be module config options which apply to all metricsets but I'm not 100% sure yet on what the exact behaviour / options will be so I ignored it for now.

return port
}

func GetConfig24(metricset string) map[string]interface{} {

Choose a reason for hiding this comment

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

exported function GetConfig24 should have comment or be unexported

return host
}

func GetEnvPort24() string {

Choose a reason for hiding this comment

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

exported function GetEnvPort24 should have comment or be unexported

@@ -27,3 +27,29 @@ func GetConfig(metricset string) map[string]interface{} {
"hosts": []string{GetEnvHost() + ":" + GetEnvPort()},
}
}

func GetEnvHost24() string {

Choose a reason for hiding this comment

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

exported function GetEnvHost24 should have comment or be unexported

@ruflin ruflin removed the in progress Pull request is currently in progress. label Apr 19, 2018
Copy link
Contributor

@exekias exekias left a comment

Choose a reason for hiding this comment

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

WFG

@exekias
Copy link
Contributor

exekias commented Apr 19, 2018

Tests are failing, I think it's related to ELASTICSEARCH_HOST env vars

This adds the index metricset to the Elasticsearch module. For now it only contains very basic metrics and is marked experimental.

This PR is used to create the basic for adding tests with the fetch reporter v2 interface and also generate data with it.

It also adds basic utility functions to fetch Master or Node information in the Elasticsearch module.
@@ -1,5 +1,3 @@
=== Elasticsearch node_stats metricset
Copy link
Member Author

Choose a reason for hiding this comment

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

This is cleanup and should not have been here. First though was this cause the doc build issue.

==== 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.

@exekias
Copy link
Contributor

exekias commented Apr 19, 2018

jenkins, retest this please

Copy link
Contributor

@exekias exekias left a comment

Choose a reason for hiding this comment

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

Ready for merge

@exekias exekias merged commit 7db33f2 into elastic:master Apr 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants