-
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
Get rid of errors generated by xpack code for elasticsearch/shard
metricset
#8192
Get rid of errors generated by xpack code for elasticsearch/shard
metricset
#8192
Conversation
@@ -62,6 +62,21 @@ func eventsMapping(r mb.ReporterV2, content []byte) { | |||
event := mb.Event{} | |||
|
|||
fields, _ := schema.Apply(shard) | |||
|
|||
// Handle node field: could be string or null | |||
err = elasticsearch.PassThruField("node", shard, fields) |
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.
What is the expected behaviour if a field is null
? What I mean by that what should it be in the event sent to Elasticsearch? Should the field not exist or have a default value?
Could you add a test json output with such null values? https://github.com/elastic/beats/blob/master/metricbeat/module/elasticsearch/shard/_meta/data.json (this data.json should probably be versioned too as in other places)
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.
Hmm, good question, thanks for bringing it up. I think in the non-xpack case, we should not index the field if it's value is null
. This is the convention we've been following in the rest of Metricbeat, IIRC, and I don't see any reason specific to this metricset to deviate from it. I'll fix the code here accordingly.
And I'll add a sample data.json
output, with version.
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.
SGTM for null
values.
I actually above linked to the wrong file. Where I wanted to link to is here: https://github.com/elastic/beats/tree/master/metricbeat/module/elasticsearch/shard/_meta/test Inside this directory we can add different versions for testing. Sorry about the confusion related to this I created.
if err != nil { | ||
continue | ||
} | ||
|
||
event.ModuleFields = common.MapStr{} | ||
event.ModuleFields.Put("node.name", fields["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.
@ruflin Should this field be at the module level or the metricset level in the event document? As you can see it is currently at the module level. However, it is not mentioned in https://github.com/elastic/beats/blob/master/metricbeat/module/elasticsearch/_meta/fields.yml#L12-L26
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.
It should be on the module level and it works because it's defined here: https://github.com/elastic/beats/blob/master/metricbeat/module/elasticsearch/node/_meta/fields.yml#L7 Not sure where we should put it as part of the module fields.yml or as part of the node fields.yml
@ruflin This PR is ready for review again. I made sure via testing that if I also regenerated Finally, I also added |
@ruflin The latest CI failure is this:
Basically, now that I've renamed |
I would leave |
See my comment in the PR about |
elasticsearch/shards
metricsetelasticsearch/shard
metricset
The only CI failure on this PR is #8208. So merging this PR now... |
…etricset (#8192) (#8285) * Refactoring: Extract passthruFields function for broader use * Passthru fields that could sometimes by null * Do not report errors in xpack path as they will go into metricbeat index * Un-hardcode index name * More fixes * Regenerating data.json * Fixing order * Renaming data JSON file to include version * Renaming data.700.json back to data.json * Adding unit test fixture for 7.0.0
I was testing the
elasticsearch/shard
metricset withxpack.enabled: true
onmaster
and ran into a few errors:Investigating a bit I found that:
node
andrelocating_node
can sometimes be returned asnull
in theGET _cluster/state/version,master_node,nodes,routing_table
Elasticsearch API response used by this metricset, andnumber
field has been renamed in the Elasticserach API response toshard
now. I can't find when it wasnumber
but it is definitelyshard
now.This PR updates the code to get rid of these errors.
It also un-hardcodes the name of the monitoring index set in
data_xpack.go
.Testing this PR
Enable the
elasticsearch
metricset:Edit
modules.d/elasticsearch.yml
and setmetricsets: [ "shard" ]
andxpack.enabled: true
.Run metricbeat:
Check in Elasticsearch that you don't have any documents in
metricbeat-*
for theelasticsearch
module (since we are usingxpack.enabled: true
).Check in Elasticsearch that you have documents in
.monitoring-es-6-mb-*
withtype:shard