-
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
[RAC] Populate Observability alerts table with data from alerts indices #96692
[RAC] Populate Observability alerts table with data from alerts indices #96692
Conversation
const alertsDynamicIndexPatternRoute = createObservabilityServerRoute({ | ||
endpoint: 'GET /api/observability/rules/alerts/dynamic_index_pattern', | ||
options: { | ||
tags: [], | ||
}, | ||
handler: async ({ ruleRegistry, context }) => { | ||
const ruleRegistryClient = ruleRegistry.createScopedRuleRegistryClient({ | ||
context, | ||
}); | ||
|
||
if (!ruleRegistryClient) { | ||
throw Boom.failedDependency(); | ||
} | ||
|
||
return ruleRegistryClient.getDynamicIndexPattern(); | ||
}, | ||
}); |
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 can use data.indexPatterns.getFieldsForWildcard
on client, i don't think it make sense to create a separate route for it.
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 call is done with the internal user. I assume that's not possible in the browser?
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 are right, but will it make a different in this case? AFAIK, you can't assign individual permissions to index patterns. Kibana permissions are weird as far as data goes, they are useful for limiting UI features though.
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'm not sure what you mean with "assign individual permissions to index patterns"?
* Use `MemoryRouter` in the stories and `useHistory` in the component to get the history * Replace examples with ones from "real" data * Use `() => {}` instead of `jest.fn()` in mock registry data
…a into observability-rule-apis
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 looks good as-is.
We're going to need to do something about the bundle size. The rule registry plugin has extraPublicDirs: common
so anything exported from common gets loaded on every page load. We might have to limit what's in common. Not sure where the APM increase is coming from. Haven't looked.
I suppose some increase in bundle size is acceptable since we're adding new features.
import { ObservabilityRuleRegistry } from '../plugin'; | ||
|
||
const createRuleRegistryMock = () => ({ | ||
registerType: jest.fn(), |
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 think we're trying to use these in stories, where there is no jest global.
logger: Logger; | ||
params: TParams; | ||
}): Promise<ESSearchResponse<unknown, TParams>> { | ||
// logger.debug(JSON.stringify(params, null, 2)); |
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.
Remove this?
const response = await scopedClusterClient.asCurrentUser.search({ | ||
...params, | ||
ignore_unavailable: true, | ||
}); | ||
|
||
// logger.debug(JSON.stringify(response.body, null, 2)); |
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.
Remove this?
@@ -149,6 +150,10 @@ export function registerTransactionDurationAlertType({ | |||
? { [SERVICE_ENVIRONMENT]: environmentParsed.esFieldValue } | |||
: {}), | |||
[TRANSACTION_TYPE]: alertParams.transactionType, | |||
[PROCESSOR_EVENT]: ProcessorEvent.transaction, | |||
'kibana.observability.evaluation.value': transactionDuration, |
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.
Should we have constants for these?
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.
Yeah, I do miss the constants from APM. But I'll put this one on the TODO list, I need to look at how the mappings/types are generated anyway.
Pinging @elastic/apm-ui (Team:apm) |
@elastic/kibana-operations I've created #97128 to look at the bundle size. |
packages/kbn-optimizer/limits.yml
Outdated
@@ -61,6 +61,7 @@ pageLoadAssetSize: | |||
remoteClusters: 51327 | |||
reporting: 183418 | |||
rollup: 97204 | |||
ruleRegistry: 107971 |
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.
Can start this with 100kb? It looks like it should still pass the limits check.
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.
Sure thing 👍
💚 Build SucceededMetrics [docs]Module Count
Async chunks
Page load bundle
History
To update your PR or re-run it, just comment with: |
It more than doubles page load bundles for I worked hard on reducing at least these two bundles :D can we please put an extra effort to make sure this can be avoided? Will really appreciate that. |
} | ||
|
||
return asBytes; | ||
}; |
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 don't see this file as deleted. So it was just copied over from APM?
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.
Yeah :(
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 tried copying one over, but they're all somehow connected, so ended up copying the whole folder and assuming we will start using those from APM in the near future).
@@ -28,7 +28,7 @@ type InferResponseType<TReturn> = Exclude<TReturn, undefined> extends Promise<in | |||
: unknown; | |||
|
|||
export function useFetcher<TReturn>( |
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.
Should we delete the useFetcher hook in APM to avoid the two drifting apart again?
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.
Preferably yes! But it's kind of hard to share public code right now. Hoping we can tackle that later.
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.
Wow, huuuge PR! But overall lgtm.
@shahzad31 @jbudz I've opened up a PR that hopefully reduces the page load bundle size somewhat again. I think the rule registry plugin is down to 10k and the APM one is down again as well (though it's still a small increase). #97251 |
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.
Rule registry changes LGTM! 👍
…es (elastic#96692) * Set up Observability rule APIs * Populate alerts table with data from API * Move field map types/utils to common * Format reason/link in alert type * Format reason/link in alert type * Fix issues with tsconfigs * Storybook cleanup for example alerts * Use `MemoryRouter` in the stories and `useHistory` in the component to get the history * Replace examples with ones from "real" data * Use `() => {}` instead of `jest.fn()` in mock registry data * Store/display evaluations, add active/recovered badge * Some more story fixes * Decode rule data with type from owning registry * Use transaction type/environment in link to app * Fix type issues * Fix API tests * Undo changes in task_runner.ts * Remove Mutable<> wrappers for field map * Remove logger.debug calls in alerting es client * Add API test for recovery of alerts * Revert changes to src/core/server/http/router * Use type imports where possible * Update limits * Set limit to 100kb Co-authored-by: Nathan L Smith <[email protected]>
…es (#96692) (#97399) * Set up Observability rule APIs * Populate alerts table with data from API * Move field map types/utils to common * Format reason/link in alert type * Format reason/link in alert type * Fix issues with tsconfigs * Storybook cleanup for example alerts * Use `MemoryRouter` in the stories and `useHistory` in the component to get the history * Replace examples with ones from "real" data * Use `() => {}` instead of `jest.fn()` in mock registry data * Store/display evaluations, add active/recovered badge * Some more story fixes * Decode rule data with type from owning registry * Use transaction type/environment in link to app * Fix type issues * Fix API tests * Undo changes in task_runner.ts * Remove Mutable<> wrappers for field map * Remove logger.debug calls in alerting es client * Add API test for recovery of alerts * Revert changes to src/core/server/http/router * Use type imports where possible * Update limits * Set limit to 100kb Co-authored-by: Nathan L Smith <[email protected]> Co-authored-by: Nathan L Smith <[email protected]>
@@ -61,6 +61,7 @@ pageLoadAssetSize: | |||
remoteClusters: 51327 | |||
reporting: 183418 | |||
rollup: 97204 | |||
ruleRegistry: 100000 |
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 know this is a bit late, but shouldn't this be near 0 since there's no actual UI 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.
There isn't any UI, but there is the rule registry setup/and start methods and the RuleRegistry class is exported. The bundle includes some io/fp-ts utils and the ECS field mapping, which takes up most of the space.
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.
It's down to 10kb now.
Closes #96566, #96624, #96531, #96563.
Changes to the rule registry:
Observability/APM changes: