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

Add basic index recovery metricset #7225

Merged
merged 7 commits into from
Jul 14, 2018
Merged

Conversation

ruflin
Copy link
Contributor

@ruflin ruflin commented May 31, 2018

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.

@ruflin ruflin added in progress Pull request is currently in progress. module Metricbeat Metricbeat labels May 31, 2018
@@ -0,0 +1,66 @@
package index_recovery

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

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

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

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

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

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

@ruflin ruflin force-pushed the index-recovery branch 2 times, most recently from 0173924 to 6de0631 Compare July 10, 2018 07:49
@ruflin ruflin added review and removed in progress Pull request is currently in progress. labels Jul 10, 2018
@ruflin ruflin force-pushed the index-recovery branch 2 times, most recently from 52e9a1d to e82ad36 Compare July 10, 2018 11:56
@ruflin ruflin changed the title add basic index recovery metricset Add basic index recovery metricset Jul 10, 2018
event := mb.Event{}
event.ModuleFields = common.MapStr{}
event.ModuleFields.Put("index.name", indexName)
event.MetricSetFields, err = schema.Apply(data)
Copy link
Member

Choose a reason for hiding this comment

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

err is not used

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Member

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"] {
Copy link
Member

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?

Copy link
Contributor Author

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 %}

Copy link
Member

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

Copy link
Contributor Author

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)
Copy link
Member

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?

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add them later.

Copy link
Contributor Author

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 {
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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.

ruflin added 7 commits July 13, 2018 15:48
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.
@ycombinator ycombinator merged commit 14888de into elastic:master Jul 14, 2018
@ruflin ruflin deleted the index-recovery branch July 20, 2018 13:47
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.

4 participants