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

[Telemetry] Add possibility of registering exclusive collectors for each collection #62665

Merged
merged 11 commits into from
Apr 8, 2020

Conversation

afharo
Copy link
Member

@afharo afharo commented Apr 6, 2020

Summary

In the PR #56675, the kibana_stats provided by the OSS and X-Pack collections were renamed to oss_kibana_stats to avoid them clashing with the kibana_stats stats reported by the monitoring plugin.
This was done because, after the NP migration, the order in which the collectors are registered is not ensured anymore, leading to the Monitoring plugin obtaining the kibana_stats from OSS and vice-versa.

But that change led to a few issues:

  1. The OSS code is expecting kibana_stats to exist and it is crashing when trying to collect the usage when reporting the telemetry.
  2. If we fix the OSS code to read from oss_kibana_stats, when running X-Pack, but monitoring is disabled, the kibana_stats reported by the monitoring plugin make it through the telemetry payload. And, on the other side: when monitoring is enabled, oss_kibana_stats is added to the telemetry payload.

This PR attempts to fix that issue by merging the collectors in the OSS side. According to the current implementation of each collector in the Monitoring end, they don't look to me like Monitoring or even X-Pack specific (except the "kibana_settings" collector: that one depends on the Monitoring config, so it makes sense to live there).

Fixes #62587

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@afharo afharo added bug Fixes for quality problems that affect the customer experience Feature:Telemetry v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.7.0 :Telemetry v7.8.0 labels Apr 6, 2020
@afharo afharo marked this pull request as ready for review April 6, 2020 18:06
@afharo afharo requested review from a team as code owners April 6, 2020 18:06
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

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

I'm not a collector expert, but what is the main reason to be able to register multiple providers for the same type? From an external point of view, this looks like a strange pattern and this PR a workaround to address the associated issues? (but once again, I don't have any context so please don't feel offended by the honest question 😄 )

@afharo
Copy link
Member Author

afharo commented Apr 7, 2020

I'm not a collector expert, but what is the main reason to be able to register multiple providers for the same type? From an external point of view, this looks like a strange pattern and this PR a workaround to address the associated issues? (but once again, I don't have any context so please don't feel offended by the honest question 😄 )

It is a very valid comment! The main reason why we may have 2 collectors with the same type is that there may be different ways of obtaining the stats depending on the enabled plugin.

The monitoring plugin is the perfect example for it (and, actually, the only one using this feature). As far as I understand it: for OSS and X-Pack, the collectors can assume Kibana is connected to one cluster. For Monitoring, 1 Kibana may be receiving monitoring information from multiple clusters, hence the need to overwrite some collectors.

Anyway, after taking a further look at the actual implementation of the collectors defined in the monitoring plugin. I believe they should belong in the OSS implementation rather than monitoring.

I've migrated the collectors to the OSS end and reverted the changes including the new flag onlyForCollectionName.

That will much simplify the future fix for the issue #58249.

@afharo afharo requested a review from a team April 7, 2020 17:27
@afharo
Copy link
Member Author

afharo commented Apr 7, 2020

Pinging @elastic/stack-monitoring-ui because it looks like the CODEOWNERS file is not properly updated after their NP migration and they are not mentioned

@afharo afharo added the review label Apr 7, 2020
@afharo afharo requested a review from pgayvallet April 7, 2020 17:28
@afharo
Copy link
Member Author

afharo commented Apr 7, 2020

@elasticmachine merge upstream

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

A ran the code locally and confirmed that this PR resolves the original issue.
Now that telemetry is enabled by default, the changes make sense.
LGTM.

@chrisronline
Copy link
Contributor

@afharo Thanks for the ping and doing this work!

Apologies for this:

The OSS code is expecting kibana_stats to exist and it is crashing when trying to collect the usage when reporting the telemetry.

I'm going to review this today or tomorrow

Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work here!

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@afharo afharo merged commit 028313a into elastic:master Apr 8, 2020
@afharo afharo deleted the telemetry/no-usage-when-oss branch April 8, 2020 08:09
afharo added a commit to afharo/kibana that referenced this pull request Apr 8, 2020
…ach collection (elastic#62665)

* [Telemetry] Add posibility of regitering exclusive collectors for collections

* [Telemetry] Filter unwanted fields from the kibana.os telemetry payload

* Filter the collectors properly in bulkFetch

* Move "kibana" usage collector from Monitoring to OSS Telemetry

* Remove exclusivity of the "kibana_settings" collector

* Unify "kibana_stats" collector from Monitoring and Legacy

* Remove unused legacy constants

* Proper type for UsageCollectionSetup in monitoring

* Missed one undo

* Add unit tests to the migrated collectors

Co-authored-by: Elastic Machine <[email protected]>
afharo added a commit to afharo/kibana that referenced this pull request Apr 8, 2020
…ach collection (elastic#62665)

* [Telemetry] Add posibility of regitering exclusive collectors for collections

* [Telemetry] Filter unwanted fields from the kibana.os telemetry payload

* Filter the collectors properly in bulkFetch

* Move "kibana" usage collector from Monitoring to OSS Telemetry

* Remove exclusivity of the "kibana_settings" collector

* Unify "kibana_stats" collector from Monitoring and Legacy

* Remove unused legacy constants

* Proper type for UsageCollectionSetup in monitoring

* Missed one undo

* Add unit tests to the migrated collectors

Co-authored-by: Elastic Machine <[email protected]>
afharo added a commit that referenced this pull request Apr 8, 2020
…ach collection (#62665) (#62912)

* [Telemetry] Add posibility of regitering exclusive collectors for collections

* [Telemetry] Filter unwanted fields from the kibana.os telemetry payload

* Filter the collectors properly in bulkFetch

* Move "kibana" usage collector from Monitoring to OSS Telemetry

* Remove exclusivity of the "kibana_settings" collector

* Unify "kibana_stats" collector from Monitoring and Legacy

* Remove unused legacy constants

* Proper type for UsageCollectionSetup in monitoring

* Missed one undo

* Add unit tests to the migrated collectors

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
afharo added a commit that referenced this pull request Apr 8, 2020
…ach collection (#62665) (#62913)

* [Telemetry] Add posibility of regitering exclusive collectors for collections

* [Telemetry] Filter unwanted fields from the kibana.os telemetry payload

* Filter the collectors properly in bulkFetch

* Move "kibana" usage collector from Monitoring to OSS Telemetry

* Remove exclusivity of the "kibana_settings" collector

* Unify "kibana_stats" collector from Monitoring and Legacy

* Remove unused legacy constants

* Proper type for UsageCollectionSetup in monitoring

* Missed one undo

* Add unit tests to the migrated collectors

Co-authored-by: Elastic Machine <[email protected]>

Co-authored-by: Elastic Machine <[email protected]>
wayneseymour pushed a commit that referenced this pull request Apr 8, 2020
…ach collection (#62665)

* [Telemetry] Add posibility of regitering exclusive collectors for collections

* [Telemetry] Filter unwanted fields from the kibana.os telemetry payload

* Filter the collectors properly in bulkFetch

* Move "kibana" usage collector from Monitoring to OSS Telemetry

* Remove exclusivity of the "kibana_settings" collector

* Unify "kibana_stats" collector from Monitoring and Legacy

* Remove unused legacy constants

* Proper type for UsageCollectionSetup in monitoring

* Missed one undo

* Add unit tests to the migrated collectors

Co-authored-by: Elastic Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes review v7.7.0 v7.8.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Telemetry] Empty usage when running in OSS mode
6 participants