-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Monitoring] Metricbeat migration status logic #34871
[Monitoring] Metricbeat migration status logic #34871
Conversation
💚 Build Succeeded |
Pinging @elastic/stack-monitoring |
Any reason these APIs are |
They both accept optional parameters (which aren't actually documented in the route defintion, so I need to do that) which are currently only used for testing. Maybe this is a bad idea? I needed someway to make the api integration tests work since the data for those tests isn't live |
x-pack/plugins/monitoring/server/routes/api/v1/setup/cluster_setup_status.js
Outdated
Show resolved
Hide resolved
With the cleanup you'll do for #34871 (comment), there's a non-test-only reason for the APIs to be |
x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.js
Show resolved
Hide resolved
x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.js
Show resolved
Hide resolved
x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.js
Show resolved
Hide resolved
I've gotten through all 3 Main Testing items so far and it's looking great! I'll finish off the remaining two test cases shortly. |
💔 Build Failed |
I called the cluster-specific API with a non-existent cluster UUID like so:
I still got a |
I've gone through all test cases. There are a couple of unresolved comments, but otherwise this is looking very good! |
I updated the description to include testing details for APM which was just recently fixed |
💔 Build Failed |
💚 Build Succeeded |
@chrisronline I see you added a change for APM and addressed my |
@ycombinator Thanks for the reminder. Our current queries (at least I don't think so) make it possible to detect a cluster existing or not, so assuming that's true, we'd have to add a query to just check that. Does that seem accurate to you? |
I'm not sure, I'll have to dig into the code to figure this out. I'll do that now and get back to you with what I find. |
💔 Build Failed |
💚 Build Succeeded |
x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.js
Outdated
Show resolved
Hide resolved
x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.js
Outdated
Show resolved
Hide resolved
return false; | ||
} | ||
|
||
return get(bucket, 'beat_type.buckets[0].key') === 'apm-server'; |
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.
Given that you're using _.get
here, do you need the guard for bucket.beat_type
above?
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.
Sorry, I wasn't clear (or maybe what I'm proposing won't work) but I was thinking this function could just become:
function isBeatFromAPM(bucket) {
return get(bucket, 'beat_type.buckets[0].key') === 'apm-server';
}
If bucket
does not have a beat_type
key, _.get
should return a falsy value. Comparing that with apm-server
would return false
. So you wouldn't need the guard check.
x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.js
Show resolved
Hide resolved
* detected: { | ||
* doesExist: boolean, // This product definitely exists but does not have any monitoring documents (kibana and ES) | ||
* mightExist: boolean, // This product might exist based on the presence of some other indices | ||
* } |
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.
❤️ this comment.
x-pack/plugins/monitoring/server/lib/setup/collection/get_collection_status.js
Outdated
Show resolved
Hide resolved
loadTestFile(require.resolve('./kibana_exclusive_mb')); | ||
loadTestFile(require.resolve('./es_and_kibana_mb')); | ||
loadTestFile(require.resolve('./es_and_kibana_exclusive_mb')); | ||
loadTestFile(require.resolve('./detect_beats')); |
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've got ES, Kibana, and Beats covered here. Do you think we should add coverage for APM and Logstash too?
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.
Yup definitely should. Thanks for the reminder
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.
To be clear, this would just cover the detection logic. I'm not sure we can test between -mb-
indices and non -mb-
indices for beats, logstash or APM? Am I understanding that correctly? Because beats and APM won't be generating those indices and logstash doesn't support that yet
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.
Your understanding is accurate.
At some point (hopefully soon) we'll have -mb-
indices for Logstash. At that time we'd want to come back and add coverage for those here. For a future PR, of course!
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.
Reviewed code and left comments.
Thanks @ycombinator. I addressed most of your comments. Will work on adding those additional tests |
💚 Build Succeeded |
💔 Build Failed |
💚 Build Succeeded |
@ycombinator I added those tests and this is ready for another round, thanks! |
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.
LGTM. Nice work! 👏👏👏
Looking forward to the the rest of the steps!
* Initial logic and tests for this * Improve test * Some cleanup and adding api integration tests * Add comments * Account for no documents returned * Add detection logic and tests * Ensure these fields are optional * Update detection logic * Beats, logstash and apm can only possibly exist * Fix some issues with APM * Fix tests * Small updates based on needing to also include the filebeat index * Fix issue with the reduce * PR feedback * More PR feedback * Add additional tests * Add additional tests
* Initial logic and tests for this * Improve test * Some cleanup and adding api integration tests * Add comments * Account for no documents returned * Add detection logic and tests * Ensure these fields are optional * Update detection logic * Beats, logstash and apm can only possibly exist * Fix some issues with APM * Fix tests * Small updates based on needing to also include the filebeat index * Fix issue with the reduce * PR feedback * More PR feedback * Add additional tests * Add additional tests
Backport: 7.x: bf9cf47 |
💔 Build Failed |
Relates to #39010
This is step 1 from the ticket linked above. It contains the server logic and endpoint necessary to determine the migration state of each product based on the existence of certain indices.
We perform a single query across all monitoring indices, using a terms agg on the
_index
field. Then, we perform multiple terms subaggs for each stack product, determining from which product instance uuid the index exists for. Then, we collect the response and determine the state for each product: fully migrated, partially migrated, or internally collected.As a way to provide support for a net new user experience (where the user has no monitoring setup), we are also attempting to detect the existence of certain products (mainly beats and logstash) based on the presence of other indices. This is a bit limiting as it will only look at the dedicated monitoring cluster for these indices (maybe we should do a CCS search here?) but it should provide some help.
This PR contains both mocha server tests and api integration tests (which is the majority of this diff).
Testing
Testing is limited to just Kibana and ES for the main part, but Logstash and Beats should be used for detection testing.
Main Testing - Part 1
/api/monitoring/v1/setup/collection
)Main Testing - Part 2
/api/monitoring/v1/setup/collection
)Main Testing - Part 3
/api/monitoring/v1/setup/collection
)Detect Testing
/api/monitoring/v1/setup/collection
)Multi-Cluster Testing
/api/monitoring/v1/setup/collection
)/api/monitoring/v1/setup/collection/{clusterUuid}
)APM Testing
./scripts/compose.py start --with-opbeans-node --no-kibana master
/api/monitoring/v1/setup/collection
)