-
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
adds ability to fetch Alert and Alert Instance state #56625
Conversation
* master: (42 commits) Move kuery_autocomplete ⇒ NP (elastic#56607) [ML] Functional tests - stabilize job row and analytics result view assertions (elastic#56595) [Discover] Inline angular directives only used in this plugin (elastic#56119) [Discover] Migrate get_sort.js test from mocha to TypeScript (elastic#56011) [SIEM] Enable flow_target_select_connected unit tests (elastic#55618) Start consuming np logging config (elastic#56480) [SIEM] Add eslint-plugin-react-perf (elastic#55960) Mention changed SAML ACS endpoint URL in breaking changes doc. (elastic#56613) Add `getServerInfo` API to http setup contract (elastic#56636) Updates Monitoring alert Jest snapshots Kibana property config migrations (elastic#55937) Vislib replacement toggle (elastic#56439) [Uptime] Add unit tests for QueryContext time calculation (elastic#56671) [SIEM][Detection Engine] Critical blocker, fixes pre-packaged rule miscounts Upgrade EUI to v18.3.0 (elastic#56228) [Maps] Fix server log (elastic#56679) [SIEM] Fixes FTUE when APM node is present (elastic#56574) [Reporting/FieldFormats] expose `setFieldFormats` and call from ReportingPlugin.start (elastic#56563) Update EMS API urls for production (elastic#56657) Ability to delete alerts even when AAD is out of sync (elastic#56543) ...
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
* master: (23 commits) Properly handle password change for users authenticated with provider other than `basic`. (elastic#55206) Improve pull request template proposal (elastic#56756) Only change handlers as the element changes (elastic#56782) [SIEM][Detection Engine] Final final rule changes (elastic#56806) [SIEM][Detection Engine] critical blocker, wrong ilm policy, need to match beats ilm policy Move ui/agg_types in to shim data plugin (elastic#56353) [SIEM] Fixes Signals count spinner (elastic#56797) [docs] Update upgrade version path (elastic#56658) [Canvas] Use unique Id for Canvas Embeddables (elastic#56783) [Rollups] Adjust max width for job detail panel (elastic#56674) Prevent http client from converting our form data (elastic#56772) Disable creating alerts client instances when ESO plugin is using an ephemeral encryption key (elastic#56676) Bumps terser-webpack-plugin to 2.3.4 (elastic#56662) Advanced settings component registry ⇒ kibana platform plugin (elastic#55940) [Endpoint] EMT-67: add kql support for endpoint list (elastic#56328) Implement UI for Create Alert form (elastic#55232) Fix: Filter pill base coloring (elastic#56761) fix open close signal on detail page (elastic#56757) [Search service] Move loadingCount to sync search strategy (elastic#56335) Rollup TSVB integration: Add test and fix warning text (elastic#56639) ...
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, made a lot of comments, none critical
x-pack/legacy/plugins/alerting/server/alert_instance/alert_instance.test.ts
Show resolved
Hide resolved
// decode | ||
value => { | ||
const decoded = new Date(value); | ||
return isNaN(decoded.getTime()) ? t.failure(valueToDecode, context) : t.success(decoded); |
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 think the getTime()
is needed on the decoded.getTime()
, but perhaps it's a bit arcane without it; I always try it in a REPL tot make sure, eg ... :-)
> isNaN(new Date('foo'))
true
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.
So, REPL says you're right, but Typescript disagrees.
It insists new Date() returns a Date, which is true, and so can't be passed as a number to isNaN, which is also true.
The REPL is relying on the coercion that JS automatically applies, but TS dosn't allow you to get away with that.
x-pack/legacy/plugins/alerting/server/task_runner/alert_task_instance.ts
Outdated
Show resolved
Hide resolved
@@ -192,8 +199,11 @@ export class TaskRunner { | |||
} | |||
|
|||
return { | |||
alertTypeState: updatedAlertTypeState, | |||
alertInstances: instancesWithScheduledActions, | |||
alertTypeState: updatedAlertTypeState || undefined, |
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 can't quite tell how close to ES this is, but remember that if we "update" a doc instead of "re-index" it, you would have to pass a null
to "delete" the existing property in the ES index. I guess we should probably make sure the io-ts encode()
is handling this, if needed.
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.
ah, interesting.
This isn't actually a change, as it was a void
before, which is an undefined
from a function that doesn't return anything.
This has only now become an issue because we're actually typing this exchange!
Any idea what the expected behaviour would be? Would an AlertExecutor that returns no state be expected to wipe out previous state or keep what was there before?
I might split this possible change off of this PR as it feels like it's worth a discussion on its own.
As it stands, an executor won't be able to return null
as we haven't marked that as a valid return type (unless they aren't using TS... 🤦♂ ) so feels like a separate conversation.
"waitUntilStarted": [MockFunction], | ||
} | ||
`); | ||
TaskManager { |
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 curious if this test is even useful. It doesn't bring me joy :-)
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.
That's a fair question, it's left overs from Legacy IMHO, but until we migrate everything to TS and NP, feels like this is still worth keeping around?
x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/get_alert_state.ts
Show resolved
Hide resolved
expect(alertInstances.length).to.eql(response.body.alertTypeState.runCount); | ||
alertInstances.forEach(([key, value], index) => { | ||
expect(key).to.eql(`instance-${index}`); | ||
expect(value.state).to.eql({ instanceStateValue: true }); |
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 wonder if the instanceStateValue
should be something different, to be on the safe side. Perhaps the index
value of the instance + runCount
.
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 LGTM outside of @pmuellr's comments 👍
…t-state * upstream/master: (96 commits) top nav ts arg support (elastic#56984) [SIEM][detection engine] Limit network rules to filebeat source semantics (elastic#57130) Add docs for alerting and action settings (elastic#57035) Add Test to Verify Endpoint App Landing Page (elastic#57129) Update `markdown-to-jsx` (`6.9.3` → `6.11.0`) and `url-parse` (`1.4.4` → `1.4.7`) dependencies. (elastic#57126) chore(NA): removes use of parallel option in the terser minimizer (elastic#57077) [ML] New Platform server shim: update file data visualizer routes to use new platform router (elastic#56972) Specifying valid licenses for the Graph feature (elastic#55911) [APM][docs] Add troubleshooting for non-indexed fields (elastic#54948) [ML] DF Analytics creation: update schema definition for create route (elastic#56979) Remove Kibana a11y guide in favor of EUI (elastic#57021) [Logs UI] Set streamLive false in URL state when arriving from link-to (elastic#56329) [docs] Fix spaces api example json (elastic#50411) Add new config for filebeat index name (elastic#56920) [Metrics-UI] Fix toolbar popover for metrics table row (elastic#56796) Saved Objects testing (elastic#56965) Disabled categorization stats validation (elastic#57087) [Rollups] Server NP migration (elastic#55606) [Metrics UI] Limit group by selector to only 2 fields (elastic#56800) fix auto closing new vis modal when navigating to lens or when navigating away with browser history (elastic#56998) ...
Added missing api on mock TM
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
Enables access to the Alert State, which allows us to see which current Alert Instances are active. This includes: 1. Addition of a `get` api on Task Manager 2. Typing and validation on Serialisation & Deserialisation of the State of an Alert's underlying Task 3. Addition of the `getAlertState` api on AlertsClient
Enables access to the Alert State, which allows us to see which current Alert Instances are active. This includes: 1. Addition of a `get` api on Task Manager 2. Typing and validation on Serialisation & Deserialisation of the State of an Alert's underlying Task 3. Addition of the `getAlertState` api on AlertsClient
Summary
Enables access to the Alert State, which allows us to see which current Alert Instances are active.
This includes:
get
api on Task ManagergetAlertState
api on AlertsClientcloses #48442
Checklist
Use
strikethroughsto remove checklist items you don't feel are applicable to this PR.This was checked for cross-browser compatibility, including a check against IE11Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n supportThis was checked for keyboard-only and screenreader accessibilityFor maintainers