-
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
[Stack Monitoring] Adds optional debug logging for Stack Monitoring #107711
[Stack Monitoring] Adds optional debug logging for Stack Monitoring #107711
Conversation
8a2726c
to
3c407d1
Compare
RequestHandlerContextMonitoringPlugin, | ||
} from './types'; | ||
|
||
import { Globals, EndpointTypes } from './static_globals'; | ||
import { instantiateClient } from './es_client/instantiate_client'; | ||
|
||
// This is used to test the version of kibana | ||
const snapshotRegex = /-snapshot/i; |
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.
All the changes above this line are just prettier import reorganization
@@ -6,53 +6,52 @@ | |||
*/ |
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.
changes at the top of this file are all prettier import reorganization
requireUIRoutes(this.monitoringCore, { | ||
if (config.ui.debug_mode) { | ||
this.log.info('MONITORING DEBUG MODE: ON'); | ||
} |
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.
I should add another log line to mention which file it's writing to, if any
const routes = Object.keys(uiRoutes); | ||
const server = config.ui.debug_mode |
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.
Check 1 of 2 to make sure we only decorate this server object if debug_mode is on...
// bail if the proper config value is not set (extra protection) | ||
if (!config.ui.debug_mode) { | ||
return _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.
Check 2 of 2 to make sure we ONLY screw around with this server object if debug_mode is turned on...
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.
Looks good! Couple suggestions on how to resolve some type TODOs though since _server
is an any
I'm not sure if they'd work. Feel free to merge either way.
// maintain the rest of _server untouched | ||
..._server, | ||
// TODO: replace any | ||
route: (options: any) => { |
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.
Maybe replace any
with:
type ServerRouteFn = typeof _server.route;
const route: (...args: Parameters<ServerRouteFn>) => ReturnType<ServerRouteFn> = (options) => {
// ...
}
return {
..._server,
route
}
return { | ||
...cluster, | ||
// TODO: better types? | ||
callWithRequest: async (_req: typeof req, type: string, params: any) => { |
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.
Are these the same types as Parameters<typeof cluster.callWithRequest>
?
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
Summary
Adds two config options:
monitoring.ui.debug_mode: true
: (default:false
): Whentrue
, will log JSON to the Kibana logs representing every query that is run on every pagemonitoring.ui.debug_file_path: <string>
(default:''
): when set, will write these logs to a file insteadEach ndjson log line will have the following shape:
If
monitoring.ui.debug_mode
isn't set to true, nothing will change. There are two checks to make sure that nothing gets changed unless that flag is set.