-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Conversation
return clusterStruct.MasterNode, nil | ||
} | ||
|
||
func GetInfo(http *helper.HTTP, uri string) (*Info, error) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
metricbeat/mb/testing/modules.go
Outdated
return r.events | ||
} | ||
|
||
func (r *CapturingReporterV2) GetErrors() []error { |
There was a problem hiding this comment.
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
metricbeat/mb/testing/modules.go
Outdated
r.errs = append(r.errs, err) | ||
return true | ||
} | ||
|
||
func (r *CapturingReporterV2) GetEvents() []mb.Event { |
There was a problem hiding this comment.
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
metricbeat/mb/testing/modules.go
Outdated
events []mb.Event | ||
errs []error | ||
} | ||
|
||
func (r *capturingReporterV2) Event(event mb.Event) bool { | ||
func (r *CapturingReporterV2) Event(event mb.Event) bool { |
There was a problem hiding this comment.
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
metricbeat/mb/testing/modules.go
Outdated
@@ -151,25 +151,33 @@ func NewReportingMetricSetV2(t testing.TB, config interface{}) mb.ReportingMetri | |||
return reportingMetricSetV2 | |||
} | |||
|
|||
type capturingReporterV2 struct { | |||
type CapturingReporterV2 struct { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 ..."
There was a problem hiding this 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
metricbeat/metricbeat.reference.yml
Outdated
metricsets: | ||
#- "index" | ||
- "node" | ||
- "node_stats" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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{} { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
0303367
to
d826677
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WFG
Tests are failing, I think it's related to ELASTICSEARCH_HOST env vars |
5cc0087
to
70d26a4
Compare
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.
70d26a4
to
1581858
Compare
@@ -1,5 +1,3 @@ | |||
=== Elasticsearch node_stats metricset |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
jenkins, retest this please |
… the index.asciidoc metricset doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready for merge
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.