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

Adding cluster_stats metricset for elasticsearch module #7638

Merged

Conversation

ycombinator
Copy link
Contributor

@ycombinator ycombinator commented Jul 18, 2018

This PR adds a cluster_stats metricset for the elasticsearch Metricbeat module. Only an initial set of fields are added by this PR.

For follow up PRs

  • Adding event generation for X-Pack Monitoring indices.
  • Adding more fields, as necessary.

@ycombinator ycombinator added in progress Pull request is currently in progress. Metricbeat Metricbeat v7.0.0-alpha1 labels Jul 18, 2018
// specific language governing permissions and limitations
// under the License.

package cluster_stats

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

// specific language governing permissions and limitations
// under the License.

package cluster_stats

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

// specific language governing permissions and limitations
// under the License.

package cluster_stats

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

// specific language governing permissions and limitations
// under the License.

package cluster_stats

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


// +build !integration

package cluster_stats

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

@ycombinator ycombinator force-pushed the metricbeat/elasticsearch/cluster-stats branch from d579910 to bebda92 Compare July 18, 2018 23:27
@ycombinator ycombinator added review and removed in progress Pull request is currently in progress. labels Jul 18, 2018
"id": "njqU4EQaTROIDlWPeUMQyw",
"name": "elasticsearch",
"stats": {
"indices": {
Copy link
Member

Choose a reason for hiding this comment

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

How does the cluster index data overlap with the index and node_stats metricset data?

Copy link
Contributor Author

@ycombinator ycombinator Jul 19, 2018

Choose a reason for hiding this comment

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

  • index metricset has docs, segments, and store which are also present in this metricset here.

  • node_stats metricset has docs, segments, and store, which are also present in this metricset here.

  • node_stats metricset also has fs and jvm stats, which are currently not present in this metricset here but are available from the Elasticsearch GET _cluster/stats API.

  • This metricset here has shards which is absent in the index metricset and also not available from the Elasticsearch GET _stats API.

  • This metricset here has shards which is absent in the node_stats metricset and also not available from the Elasticsearch GET _nodes/_local API or the GET _nodex/_local/stats API.

  • This metricset here has fielddata which is absent in the index metricset but is available from the Elasticsearch GET _stats API.

  • This metricset here has fielddata which is absent in the node_stats metricset and also not available from the Elasticsearch GET _nodes/_local API. However it is available from the Elasticsearch GET _nodes/_local/stats API. Of course, the latter API is missing a bunch of other fields that are present in the former API so either we call both or we ask the ES team to enhance the latter API's response to include all the fields we use from the former API's response as well.

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 do need to fix the field names in this metricset here so they match up with the ones in other elasticsearch metricsets (e.g. I need to use count instead of total, etc.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Field names fixed in 6662787.

Copy link
Member

Choose a reason for hiding this comment

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

Should we report all the data we have in the index and node_stats metricset here too? Or should we focus on the data points that other metricsets don't have?

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 think to start off we can only report the stats that are not already covered by other metricsets. Concretely, those would be fielddata and shards fields.

Copy link
Member

Choose a reason for hiding this comment

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

++

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 27ef3fb.


event.ModuleFields = common.MapStr{}
event.ModuleFields.Put("cluster.name", info.ClusterName) // TODO cluster_name from cluster stats response could be used here?
event.ModuleFields.Put("cluster.id", info.ClusterID) // TODO: Can we get this returned in cluster stats response itself?
Copy link
Member

Choose a reason for hiding this comment

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

++

I think both values are a must to be returned y cluster stats API

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created elastic/elasticsearch#32205 to request cluster UUID from cluster stats API itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... and put up PR as well: elastic/elasticsearch#32206

Copy link
Member

Choose a reason for hiding this comment

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

Keep in mind that older versions of ES will not have it in, so in these cases we need to skip it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Should we skip it or make the extra API call in that case (I realize that complicates the logic/organization of the code a fair bit)?

Copy link
Member

Choose a reason for hiding this comment

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

Lets skip it to not add more complexity. New versions, new features :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in ed74319b4.

@ycombinator ycombinator force-pushed the metricbeat/elasticsearch/cluster-stats branch from ed74319 to 290e7a8 Compare July 23, 2018 18:07
Copy link
Member

@ruflin ruflin left a comment

Choose a reason for hiding this comment

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

Code LGTM. Could you add a CHANGELOG entry?

- name: count
type: long
description: >
Total number of shards in cluster
Copy link
Member

Choose a reason for hiding this comment

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

Apply to all lines: I think normally we put a dot at the end for the docs.

@@ -0,0 +1,147 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

Can we also have one for 630?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in a5953bd.

@ruflin
Copy link
Member

ruflin commented Jul 24, 2018

@ycombinator Looks like this could be merged before the ES PR is merged as we do check if the field exists?

Could you rebase and directly squash the commits?

@ycombinator
Copy link
Contributor Author

Yes, good point @ruflin. I will fix up this PR now so it can be reviewed/merged soon.

@ycombinator ycombinator force-pushed the metricbeat/elasticsearch/cluster-stats branch 2 times, most recently from 346ba91 to 69ee642 Compare July 24, 2018 12:01
@ycombinator
Copy link
Contributor Author

ycombinator commented Jul 24, 2018

Alright, all squashed up into 766b7f3 and ready for review/merge. Thanks @ruflin!

@ycombinator ycombinator force-pushed the metricbeat/elasticsearch/cluster-stats branch from 69ee642 to 766b7f3 Compare July 24, 2018 15:23
@ruflin ruflin merged commit beada5f into elastic:master Jul 24, 2018
@ycombinator ycombinator deleted the metricbeat/elasticsearch/cluster-stats branch July 30, 2018 22:24
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.

3 participants