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

[Elasticsearch Monitoring] Add cluster_metadata to cluster_stats docs #8445

Conversation

ycombinator
Copy link
Contributor

Porting over elastic/elasticsearch#33860 to the Metricbeat Elasticsearch module (X-Pack Monitoring code path).

This PR teaches Elasticsearch X-Pack Monitoring to collect cluster metadata, if any is set, and index it into cluster_stats docs in .monitoring-es-6-mb-*.

After this PR, cluster_stats docs in .monitoring-es-6-mb-* will contain an additional top-level cluster_settings field like so:

{
   ...
   "cluster_settings": {
     "cluster": {
       "metadata": {
         ...
       }
     }
   }
}

@ycombinator ycombinator added review Metricbeat Metricbeat needs_backport PR is waiting to be backported to other branches. v7.0.0-alpha1 monitoring v6.5.0 labels Sep 25, 2018
@ycombinator ycombinator requested a review from ruflin September 25, 2018 23:17
}

if !hasSettingGroup {
return common.MapStr{}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you want to return here nil or an empty MapStr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we return nil here, then on the caller side we'll have to check for it and construct an empty MapStr. Otherwise this line will throw a runtime panic:

https://github.com/elastic/beats/blob/d38f1dd5801ab4fb7fb320aedc504f5e4ea060c2/metricbeat/module/elasticsearch/elasticsearch.go#L302

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about the end JSON document, what is your suggestion on what should be there?

Copy link
Contributor Author

@ycombinator ycombinator Nov 5, 2018

Choose a reason for hiding this comment

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

I decided that if there are no cluster settings, we should not have that field in the end JSON document either. This also makes it consistent with the internal ES collector implementation:

https://github.com/elastic/elasticsearch/blob/00e66bab362b1a8cd72c5fc483b8523c3888890e/x-pack/plugin/monitoring/src/main/java/org/elasticsearch/xpack/monitoring/collector/cluster/ClusterStatsMonitoringDoc.java#L169-L184

I've implemented this logic in 43fed80.

Copy link
Contributor

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

LGTM.

Only left a question for the nil part. Good with all options.

@ycombinator
Copy link
Contributor Author

ycombinator commented Oct 1, 2018

There is some discussion going on on the corresponding ES PR (elastic/elasticsearch#34023) so I'm holding off on making further changes to this PR for now.

@ycombinator ycombinator added in progress Pull request is currently in progress. and removed review labels Oct 1, 2018
@ycombinator ycombinator removed needs_backport PR is waiting to be backported to other branches. v6.5.0 labels Oct 14, 2018
@ycombinator ycombinator force-pushed the metricbeat-elasticsearch-cluster-stats-add-cluster-settings-metadata branch from d38f1dd to c305306 Compare November 5, 2018 18:59
@ycombinator
Copy link
Contributor Author

The discussion in elastic/elasticsearch#34023 has settled and the PR has been merged so I'm resuming work on this PR. I will shortly bring it up to date with the ES internal collector implementation and also address the review feedback above. Stay tuned...

@ycombinator
Copy link
Contributor Author

@ruflin I've made this PR's implementation now consistent with the internal ES collector implementation. Ready for your review again. Thanks!

@ycombinator
Copy link
Contributor Author

jenkins, test this

Copy link
Contributor

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

@@ -142,6 +142,22 @@ func apmIndicesExist(clusterState common.MapStr) (bool, error) {
return false, nil
}

func getClusterMetadataSettings(m *MetricSet) (common.MapStr, error) {
// For security reasons we only get the display_name setting
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Users can set whatever they want in the cluster metadata. They might set sensitive information, and we would end up indexing it into monitoring indices. So, to be on the safer side, we decided to just collect the specific key, display_name, from cluster metadata for now.

See complete discussion about this starting here: elastic/elasticsearch#34023 (comment).

Note that even though we only collect the specific key for now, we are indexing the complete nesting structure for the key. That way, if we later decide to allow more keys or all keys, there will be no break in the expected structure for the UI.

@ruflin
Copy link
Contributor

ruflin commented Nov 6, 2018

Should we start to add changelog entries also for the internal monitoring?

@ycombinator ycombinator added needs_backport PR is waiting to be backported to other branches. v6.6.0 labels Nov 6, 2018
@ycombinator
Copy link
Contributor Author

Should we start to add changelog entries also for the internal monitoring?

Yeah, I think we can start doing that now. The modules are getting mature enough IMO. Added for this PR in 3226279.

@ruflin I also answered your question above: #8445 (comment). Does this PR still LGTY?

@ycombinator
Copy link
Contributor Author

jenkins, test this

@ycombinator
Copy link
Contributor Author

jenkins, test this

1 similar comment
@ycombinator
Copy link
Contributor Author

jenkins, test this

@ycombinator ycombinator added review and removed in progress Pull request is currently in progress. labels Nov 8, 2018
@ycombinator ycombinator merged commit 29be670 into elastic:master Nov 8, 2018
@ycombinator ycombinator deleted the metricbeat-elasticsearch-cluster-stats-add-cluster-settings-metadata branch November 8, 2018 11:56
@ycombinator ycombinator removed the needs_backport PR is waiting to be backported to other branches. label Nov 8, 2018
ycombinator added a commit that referenced this pull request Nov 8, 2018
…data to cluster_stats docs (#8990)

Cherry-pick of PR #8445 to 6.x branch. Original message: 

Porting over elastic/elasticsearch#33860 to the Metricbeat Elasticsearch module (X-Pack Monitoring code path).

This PR teaches Elasticsearch X-Pack Monitoring to collect cluster metadata, if any is set, and index it into `cluster_stats` docs in `.monitoring-es-6-mb-*`.

After this PR, `cluster_stats` docs in `.monitoring-es-6-mb-*` will contain an additional top-level `cluster_settings` field like so:

```
{
   ...
   "cluster_settings": {
     "cluster": {
       "metadata": {
         ...
       }
     }
   }
}
```
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.

2 participants