Skip to content

Conversation

@yctercero
Copy link
Contributor

@yctercero yctercero commented Oct 10, 2020

Summary

This PR is meant to address the remaining rule query preview bugs. It addresses the following:

  • gives same loading experience for all rule query types (previously there were two different loading states)
  • makes sure noise warnings are showing for all query types and disappear on timeframe or query change
  • updates when to/from are set so it is set on preview click

Custom query

customQuery

Threshold query

thresholdQuery

Eql query

eqlQuery

Eql sequence query

eqlSequence

Checklist

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed these changes as I'm no longer using this component.

@yctercero yctercero added release_note:fix Team:Detections and Resp Security Detection Response Team labels Oct 10, 2020
@yctercero yctercero marked this pull request as ready for review October 12, 2020 16:34
@yctercero yctercero requested review from a team as code owners October 12, 2020 16:34
Copy link
Contributor

@rylnd rylnd left a comment

Choose a reason for hiding this comment

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

A few quick fixes should get the validity logic a little tighter, here, especially around EQL rules. Otherwise, this looks great!

@rylnd rylnd self-requested a review October 12, 2020 20:22
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

@kbn/optimizer bundle module count

id before after diff
securitySolution 2057 2059 +2

async chunks size

id before after diff
securitySolution 10.6MB 10.6MB +10.4KB

page load bundle size

id before after diff
securitySolution 593.2KB 600.5KB +7.2KB

History

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

@yctercero
Copy link
Contributor Author

@MikePaquette @marrasherrier getting feedback on the sequence histogram, that it's not very intuitive and not sure that it's of any added value. @madirey suggested maybe embedding resolver as it is able to visually represent event sequences, or maybe we could just show total hits when we detect that the query is a sequence?

@rylnd
Copy link
Contributor

rylnd commented Oct 13, 2020

@yctercero I was able to somewhat reliably reproduce an issue where hitting Preview did not update the UI:

  1. (re)Load the Create Rule page
  2. Choose EQL type
  3. Fill a sequence query: sequence [process where true] [process where true]
  4. Click "Preview Results"

Often, the preview request would be issued, but no UI would update/no histogram would be displayed.

Copy link
Contributor

@rylnd rylnd left a comment

Choose a reason for hiding this comment

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

This looks great! I'm really liking the rxjs stuff, I can't wait to play more with observables 🤗 .

I had one (product) question about the sequences preview histogram, and another issue with the preview button occasionally not working.

abortSignal: abortCtrl.current.signal,
}
)
.pipe(takeUntil(unsubscribeStream.current))
Copy link
Contributor

Choose a reason for hiding this comment

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

I really like this pattern! The semantics of emitting to this to unsubscribe isn't exactly intuitive (to me), but it seems like a common solution to this scoping/unsubscribing issue. There are also some eslint hooks for rxjs (e.g. no-unsafe-takeuntil) that we might want to enable

if (!didCancel.current) {
setLoading(false);
if (hasEqlSequenceQuery(query)) {
setResponse(getSequenceAggs(res, refetch.current));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think getSequenceAggs is the source of these console warnings:

DevTools_-_localhost_5601_app_security_detections_rules_create_sourcerer__default______timerange__global__linkTo___timeline__timerange__from__272020-10-13T14_40_11_422Z_27_fromStr_now-30m_kind_relative_to__272020-10-13T15_10_11_422Z_27_toSt

Since the x-values are time strings and not numbers. However, wrapping them in moment().valueOf() fixes the warning but breaks the "buckets", since the x-axis is now back to using a linear scale:

Detections_-_Kibana

Copy link
Contributor

Choose a reason for hiding this comment

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

Taking a step back, the existing histogram is somewhat surprising in its behavior. There appear to be only two buckets in this graph:

Detections_-_Kibana

Or perhaps each unique timestamp string is its own bucket? I'm not sure what the default behavior for their ordinal scale is, but the latter seems likely.

To me the graph is conveying three data points: the number of results, the number of sequences, and their distribution over time. However, distribution over time is ambiguous and potentially lossy/misleading; we may want to reconsider how we present this data for sequences.

Copy link
Contributor

Choose a reason for hiding this comment

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

Could we just preview this in an embedded Resolver?

Copy link
Contributor Author

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 have against rainbow graphs @rylnd 😜 I have a draft where I'm trying to see if displaying it in more of a Gantt type form helps. Will definitely follow up with @MikePaquette and @marrasherrier on this.

@madirey I wonder how heavy that would be, or is it already easily embeddable?

Copy link
Contributor

@madirey madirey left a comment

Choose a reason for hiding this comment

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

Tested manually with several different EQL queries. Aside from the pending questions about the histogram, this LGTM. Thank you!

@yctercero yctercero requested a review from rylnd October 13, 2020 22:14
@yctercero
Copy link
Contributor Author

Merging, with the following issues being addressed as follow up:

  • the graph sometimes not showing as pointed out by @rylnd is a race condition where some query bar state is updating after button is clicked and this sets showHistogram to true - need to memoize a few values to minimize unnecessary re-renders, that will fix this
  • continue discussion with team about best display for sequences. Working on a Gantt looking type graph, that could be useful, if not at the very least of more use than what's there now

@yctercero yctercero merged commit f8d821c into elastic:master Oct 13, 2020
yctercero added a commit to yctercero/kibana that referenced this pull request Oct 13, 2020
… bug with query preview + tests (elastic#80110)

## Summary

This PR is meant to address the remaining rule query preview bugs. It addresses the following:

- gives same loading experience for all rule query types (previously there were two different loading states)
- makes sure noise warnings are showing for all query types and disappear on timeframe or query change
- updates when to/from are set so it is set on preview click
yctercero added a commit to yctercero/kibana that referenced this pull request Oct 13, 2020
… bug with query preview + tests (elastic#80110)

## Summary

This PR is meant to address the remaining rule query preview bugs. It addresses the following:

- gives same loading experience for all rule query types (previously there were two different loading states)
- makes sure noise warnings are showing for all query types and disappear on timeframe or query change
- updates when to/from are set so it is set on preview click
yctercero added a commit that referenced this pull request Oct 14, 2020
… bug with query preview + tests (#80110) (#80424)

## Summary

This PR is meant to address the remaining rule query preview bugs. It addresses the following:

- gives same loading experience for all rule query types (previously there were two different loading states)
- makes sure noise warnings are showing for all query types and disappear on timeframe or query change
- updates when to/from are set so it is set on preview click
yctercero added a commit that referenced this pull request Oct 14, 2020
… bug with query preview + tests (#80110) (#80425)

## Summary

This PR is meant to address the remaining rule query preview bugs. It addresses the following:

- gives same loading experience for all rule query types (previously there were two different loading states)
- makes sure noise warnings are showing for all query types and disappear on timeframe or query change
- updates when to/from are set so it is set on preview click
@yctercero yctercero deleted the preview_buggies_2 branch October 14, 2020 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants