-
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
Add basic index recovery metricset #7225
Conversation
@@ -0,0 +1,66 @@ | |||
package index_recovery |
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.
don't use an underscore in package name
@@ -0,0 +1,13 @@ | |||
// +build !integration | |||
|
|||
package index_recovery |
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.
don't use an underscore in package name
@@ -0,0 +1,53 @@ | |||
package index_recovery |
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.
don't use an underscore in package name
@@ -0,0 +1,66 @@ | |||
package index_recovery |
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.
don't use an underscore in package name
@@ -0,0 +1,13 @@ | |||
// +build !integration | |||
|
|||
package index_recovery |
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.
don't use an underscore in package name
@@ -0,0 +1,53 @@ | |||
package index_recovery |
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.
don't use an underscore in package name
0173924
to
6de0631
Compare
52e9a1d
to
e82ad36
Compare
event := mb.Event{} | ||
event.ModuleFields = common.MapStr{} | ||
event.ModuleFields.Put("index.name", indexName) | ||
event.MetricSetFields, err = schema.Apply(data) |
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.
err
is not used
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 added an if err
check and send an the error event. I wonder if this is the right thing to do 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.
I now skiped the error completely. I initially reported it as an event. The good thing about it is that I detected a problem I had in the schema. The bad thing was that now instead of in the logs the user would have tons of documents in his index with errors which I think is not good.
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.
Maybe we could log the errors instead of sending them, or collect them in a multierror
and send them all together as an only event.
} | ||
|
||
for indexName, d := range data { | ||
for _, data := range d["shards"] { |
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.
Would we want to explicitely check if shards
exists?
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.
Yes
{{ k }}: {{ v }} | ||
{% endfor %} | ||
{% endfor %} | ||
|
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 wouldn't add more variables to this template, for this kind of settings, the extra
option is used In system
and munin
modules, this could be also used here (or we could also rename the extra to metricset_options
if this is the use case for extra as it seems to be used for similar things).
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, didn't reliase extra
is there.
// Fetch gathers stats for each index from the _stats API | ||
func (m *MetricSet) Fetch(r mb.ReporterV2) { | ||
|
||
isMaster, err := elasticsearch.IsMaster(m.HTTP, m.HostData().SanitizedURI+m.recoveryPath) |
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.
Is recoveryPath
used to check master state?
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 full url must be passed as this is the url that is revert to afterwards again. If not passed parts of the path will go missing. This is because of a hack to reuse the http client.
description: > | ||
index | ||
fields: | ||
- name: id |
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.
Should this be shard_id
?
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.
Kind of, see my comment in the code: https://github.com/elastic/beats/pull/7225/files#diff-d198e8deee0000763245926eefe134eaR32
TBH I'm still struggling a bit with what shard.id
is as I would expect it to be a unique identifier but it's a counting integer related to an index as far as I can see.
- name: source.name | ||
type: keyword | ||
description: > | ||
Source node name. |
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 about other fields such as translog.*
, start_time
, stop_time
, etc.? Are you planning on adding them later?
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.
Add them later.
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.
Yes, later
} | ||
) | ||
|
||
func eventsMapping(r mb.ReporterV2, info elasticsearch.Info, content []byte) 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.
Maybe I'm missing something but at first glance it looks like info
isn't actually being used 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.
You are right, I added it out of habit as the plan is to add the xpack part where it will be need I think. Should I remove it?
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.
Yeah, my preference would be to remove it until we need it. Otherwise it might be confusing as to why it's there.
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.
Ok, removed and new version pushed.
return | ||
} | ||
|
||
info, err := elasticsearch.GetInfo(m.HTTP, m.HostData().SanitizedURI+m.recoveryPath) |
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.
See my other comment about info
not being used.
Add basic metricset for index recovery. By default only data about indices is fetched that are currently recovering. Further changes: * Fix `NO_COMPOSE` flag for Golang integration tests * Clean up elasticsearch.GetInfo to also use `fetchPath` function * Enhance testing to also support settings metricset configs.
Add basic metricset for index recovery. By default only data about indices is fetched that are currently recovering.
Further changes:
NO_COMPOSE
flag for Golang integration testsfetchPath
function