Skip to content

[Uptime] Add Kuery Bar - #43621

Merged
justinkambic merged 87 commits into
elastic:masterfrom
justinkambic:uptime_kuery-bar
Sep 17, 2019
Merged

justinkambic merged 87 commits into
elastic:masterfrom
justinkambic:uptime_kuery-bar

Conversation

@justinkambic

@justinkambic justinkambic commented Aug 20, 2019 •

Copy link
Copy Markdown
Contributor

Summary

Add Kuery Bar.

Understanding this PR

This diff is rather large so I have composed the guide below to help reviewers parse and understand it. A large portion of the added code involves tests, snapshots, or code copied from APM that we will ultimately not be maintaining.

I've also taken the liberty of removing a large amount of code that this PR will make obsolete. Additionally, I've removed some code that is not in use.

Filter group

One critical part of this change that added significant complexity was keeping our existing filtering experience functional. This necessitated the creation of an additional component. Code for fetching filter values has moved from the old search bar component to here.

The way filtering now works is a combination of two criteria.

  1. The Kuery Bar - this is more-or-less unchanged under the hood from the APM version. There were some top-level additions/deletions I made when integrating it.
  2. The Filter Group - These are pre-loaded shortcuts users can employ to filter on things like ID, location, etc. When a user selects a value to filter on, a new entry is added/updated in a map that stores the filter's field name and selected values. Values in the map are or'd at the value level, and and'd at the field level.

Example:

[
  {
    'monitor.id': ['green-0001', 'green-0002']
  },
  {
    'observer.geo.name': ['us-east-1', 'us-west-2']
  }
]

yields a Kuery string like:

'(monitor.id:green-0001 or monitor.id:green-0002) and (observer.geo.name:us-east-1 or observer.geo.name:us-east-2)'

After the filter query is generated, the output of the filter and search are and'd together, an ES DSL is generated, and the resultant string is provided to the server and persisted in a new filters URL parameter.

Kuery Bar

This patch finally adds the KueryBar to Uptime. The eventual goal is for this to be a common component that is shared amongst the various Observability solutions. For this present iteration, we are copying the code from APM. I have added an declaration file for the Typeahead class, and placed some custom code in the main index.tsx file. The KueryBar places its output into the existing search URL parameter.

Server

Previously we had no control over the selection of filters applied on monitor.status, as the output of the buttons was a plaintext string. Since we have more control over the persisted filter logic, we can handle the special case of monitor.status separately; as such the server and GraphQL methods now accept a separate status flag, along with the JSON string to use as part of the Elasticsearch queries.

Testing this PR

From a UI perspective the changes in this PR are localized to the Overview page. We've added the Kuery Bar and a series of filter dropdowns. Testing this PR is fairly straightforward.

  1. Configure Heartbeat to ship Uptime data.
  2. Load this patch, attempt to use the Kuery Bar.
  3. Attempt to use the filter dropdowns.
  4. Use the filters in concert with the Kuery Bar. This means filtering by status or location, along with a monitor ID or URL in the search bar.

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@justinkambic justinkambic added release_note:enhancement v8.0.0 Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.4.0 labels Aug 20, 2019
@justinkambic justinkambic self-assigned this Aug 20, 2019
@elasticmachine

Copy link
Copy Markdown
Contributor

Pinging @elastic/uptime

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Comment thread x-pack/legacy/plugins/uptime/public/lib/helper/stringify_kueries.ts
@justinkambic

Copy link
Copy Markdown
Contributor Author

@shahzad31 @katrin-freihofner can you let me know if you're able to reproduce issues again? I think all your previous feedback is addressed at this point.

@justinkambic

Copy link
Copy Markdown
Contributor Author

jenkins test this

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@elasticmachine

Copy link
Copy Markdown
Contributor

💔 Build Failed

@katrin-freihofner

Copy link
Copy Markdown

@justinkambic looks good to me. I could not reproduce any of the issues. Nice work!

@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@shahzad31 shahzad31 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Issues are resolved and code looks clean now :)

@jasonrhodes jasonrhodes left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@justinkambic looks great to me -- there are a few things that are going to make this not work for infra/logs but we should obviously wait to address those until we build a shared version. This is a great step forward toward that!

@justinkambic

Copy link
Copy Markdown
Contributor Author

there are a few things that are going to make this not work for infra/logs but we should obviously wait to address those until we build a shared version. This is a great step forward toward that!

@jasonrhodes yeah I'm aware I injected some Uptime-specific logic but like you say, I figure we can refactor/straighten that out in the next phase. Uptime will be better situated to handle that at that point, too!

@andrewvc

Copy link
Copy Markdown
Contributor

Checked out the latest version, looks and works great in my browser!

@elasticmachine

Copy link
Copy Markdown
Contributor

💚 Build Succeeded

@justinkambic
justinkambic merged commit 4999d09 into elastic:master Sep 17, 2019
justinkambic added a commit to justinkambic/kibana that referenced this pull request Sep 18, 2019
* Add saved objects provider, auto-creation of index pattern.

* Fix outdated import.

* Add KueryBar component to Uptime app.

* Extract module helper function to higher scope for greater reuse.

* Reduce nesting in URL hook.

* Update client usage of previously-moved helper function.

* Add export for helper function to helper directory.

* Add index pattern adapter to client lib.

* Add KueryBar to Overview Page.

* Add KueryBar and new filter group.

* Move new components to appropriate directory.

* Fix overview page import.

* Delete status filter helper functions.

* Remove  from list of recommended fields.

* Update domain files to use status filter.

* Update GraphQL queries to use status filter.

* Update GraphQL endpoint to accept status filter.

* Delete obsolete component and associated files.

* Add custom filter components.

* Delete unneeded code.

* Update adapters to accept statusFilter parameter.

* Remove obsolete code.

* Alphabetize object declaration.

* Add index pattern helper function.

* Update Overview handling of filters/user search.

* Update GraphQL inferred types.

* Delete obsolete component.

* Update outdated unit test for stringify_url_params.

* Add index file to new adapter directory.

* Update test framework files to satisfy new typing requirements.

* Update test snapshot for useUrlParams.

* Update JSDoc comment in pings adapter.

* Update pings adapter tests to use new `statusFilter` parameter.

* Delete tests and fixtures for obsolete endpoints.

* Update outdated fixture.

* Update status filter usages for snapshot query tests.

* Delete obsolete imports from index file.

* Delete obsolete monitor list getter.

* Update supported URL params for new param keys.

* Remove unused prop reference.

* Improve naming in new filter components.

* Clean up function body.

* Internationalize filter components.

* Update internationalization key.

* Add test for new helper function.

* Extract function to dedicated file, add tests.

* Add tests for filter popover.

* Move FilterStatusButton to appropriate directory.

* Add test for FilterStatusButton.

* Add tests for getIndexPattern helper.

* Extract helper function to dedicated file.

* Add tests to combineFiltersAndUserSearch helper function.

* Extract inline JSX to new component and add tests.

* Remove obsolete code, update index pattern getter, and add tests.

* Add filter clause helper function and tests.

* Replace custom filter formatting code with calls to new helper function.

* Move filter components to dedicated directory.

* Rename filter files.

* Delete obsolete snapshot.

* Fix broken import in test file.

* Update a comment.

* Simplify index pattern loading in KueryBar.

* Delete unused prop.

* Extract toggle handler to external function and write tests.

* Delete obsolete int'l labels and reuse existing ones in current code.

* Delete remaining unused translation key.

* Rename a file.

* Handle numeric values for filters. Position KueryBar and FilterGroup on same line.

* Remove ID's and URL's from FilterGroup.

* Remove unneeded onOutsideClick handler from styled component to silence warning.

* Escape colons in filters.

* Escape colons in filters.

* Fix bug in snapshot code - calculate total after filtering by status.

* Add specific message to MonitorList when filters are active.

* Introduce missing prop to unit tests.

* Delete unused translation keys.

* Undo filter-related changes to snapshot adapter function.

* Remove unnecessary spread.

* Update filter popover to trap focus and improve keyboard experience.

* Update broken test snapshots.
justinkambic added a commit that referenced this pull request Sep 19, 2019
* [Uptime] Add Kuery Bar (#43621)

* Add saved objects provider, auto-creation of index pattern.

* Fix outdated import.

* Add KueryBar component to Uptime app.

* Extract module helper function to higher scope for greater reuse.

* Reduce nesting in URL hook.

* Update client usage of previously-moved helper function.

* Add export for helper function to helper directory.

* Add index pattern adapter to client lib.

* Add KueryBar to Overview Page.

* Add KueryBar and new filter group.

* Move new components to appropriate directory.

* Fix overview page import.

* Delete status filter helper functions.

* Remove  from list of recommended fields.

* Update domain files to use status filter.

* Update GraphQL queries to use status filter.

* Update GraphQL endpoint to accept status filter.

* Delete obsolete component and associated files.

* Add custom filter components.

* Delete unneeded code.

* Update adapters to accept statusFilter parameter.

* Remove obsolete code.

* Alphabetize object declaration.

* Add index pattern helper function.

* Update Overview handling of filters/user search.

* Update GraphQL inferred types.

* Delete obsolete component.

* Update outdated unit test for stringify_url_params.

* Add index file to new adapter directory.

* Update test framework files to satisfy new typing requirements.

* Update test snapshot for useUrlParams.

* Update JSDoc comment in pings adapter.

* Update pings adapter tests to use new `statusFilter` parameter.

* Delete tests and fixtures for obsolete endpoints.

* Update outdated fixture.

* Update status filter usages for snapshot query tests.

* Delete obsolete imports from index file.

* Delete obsolete monitor list getter.

* Update supported URL params for new param keys.

* Remove unused prop reference.

* Improve naming in new filter components.

* Clean up function body.

* Internationalize filter components.

* Update internationalization key.

* Add test for new helper function.

* Extract function to dedicated file, add tests.

* Add tests for filter popover.

* Move FilterStatusButton to appropriate directory.

* Add test for FilterStatusButton.

* Add tests for getIndexPattern helper.

* Extract helper function to dedicated file.

* Add tests to combineFiltersAndUserSearch helper function.

* Extract inline JSX to new component and add tests.

* Remove obsolete code, update index pattern getter, and add tests.

* Add filter clause helper function and tests.

* Replace custom filter formatting code with calls to new helper function.

* Move filter components to dedicated directory.

* Rename filter files.

* Delete obsolete snapshot.

* Fix broken import in test file.

* Update a comment.

* Simplify index pattern loading in KueryBar.

* Delete unused prop.

* Extract toggle handler to external function and write tests.

* Delete obsolete int'l labels and reuse existing ones in current code.

* Delete remaining unused translation key.

* Rename a file.

* Handle numeric values for filters. Position KueryBar and FilterGroup on same line.

* Remove ID's and URL's from FilterGroup.

* Remove unneeded onOutsideClick handler from styled component to silence warning.

* Escape colons in filters.

* Escape colons in filters.

* Fix bug in snapshot code - calculate total after filtering by status.

* Add specific message to MonitorList when filters are active.

* Introduce missing prop to unit tests.

* Delete unused translation keys.

* Undo filter-related changes to snapshot adapter function.

* Remove unnecessary spread.

* Update filter popover to trap focus and improve keyboard experience.

* Update broken test snapshots.

* Update snap.
@justinkambic

Copy link
Copy Markdown
Contributor Author

Backported to:
7.x/7.5.0 bf9f9f1
#45859

@justinkambic
justinkambic deleted the uptime_kuery-bar branch September 19, 2019 01:59
patrykkopycinski pushed a commit to patrykkopycinski/kibana that referenced this pull request May 6, 2026
* Add saved objects provider, auto-creation of index pattern.

* Fix outdated import.

* Add KueryBar component to Uptime app.

* Extract module helper function to higher scope for greater reuse.

* Reduce nesting in URL hook.

* Update client usage of previously-moved helper function.

* Add export for helper function to helper directory.

* Add index pattern adapter to client lib.

* Add KueryBar to Overview Page.

* Add KueryBar and new filter group.

* Move new components to appropriate directory.

* Fix overview page import.

* Delete status filter helper functions.

* Remove  from list of recommended fields.

* Update domain files to use status filter.

* Update GraphQL queries to use status filter.

* Update GraphQL endpoint to accept status filter.

* Delete obsolete component and associated files.

* Add custom filter components.

* Delete unneeded code.

* Update adapters to accept statusFilter parameter.

* Remove obsolete code.

* Alphabetize object declaration.

* Add index pattern helper function.

* Update Overview handling of filters/user search.

* Update GraphQL inferred types.

* Delete obsolete component.

* Update outdated unit test for stringify_url_params.

* Add index file to new adapter directory.

* Update test framework files to satisfy new typing requirements.

* Update test snapshot for useUrlParams.

* Update JSDoc comment in pings adapter.

* Update pings adapter tests to use new `statusFilter` parameter.

* Delete tests and fixtures for obsolete endpoints.

* Update outdated fixture.

* Update status filter usages for snapshot query tests.

* Delete obsolete imports from index file.

* Delete obsolete monitor list getter.

* Update supported URL params for new param keys.

* Remove unused prop reference.

* Improve naming in new filter components.

* Clean up function body.

* Internationalize filter components.

* Update internationalization key.

* Add test for new helper function.

* Extract function to dedicated file, add tests.

* Add tests for filter popover.

* Move FilterStatusButton to appropriate directory.

* Add test for FilterStatusButton.

* Add tests for getIndexPattern helper.

* Extract helper function to dedicated file.

* Add tests to combineFiltersAndUserSearch helper function.

* Extract inline JSX to new component and add tests.

* Remove obsolete code, update index pattern getter, and add tests.

* Add filter clause helper function and tests.

* Replace custom filter formatting code with calls to new helper function.

* Move filter components to dedicated directory.

* Rename filter files.

* Delete obsolete snapshot.

* Fix broken import in test file.

* Update a comment.

* Simplify index pattern loading in KueryBar.

* Delete unused prop.

* Extract toggle handler to external function and write tests.

* Delete obsolete int'l labels and reuse existing ones in current code.

* Delete remaining unused translation key.

* Rename a file.

* Handle numeric values for filters. Position KueryBar and FilterGroup on same line.

* Remove ID's and URL's from FilterGroup.

* Remove unneeded onOutsideClick handler from styled component to silence warning.

* Escape colons in filters.

* Escape colons in filters.

* Fix bug in snapshot code - calculate total after filtering by status.

* Add specific message to MonitorList when filters are active.

* Introduce missing prop to unit tests.

* Delete unused translation keys.

* Undo filter-related changes to snapshot adapter function.

* Remove unnecessary spread.

* Update filter popover to trap focus and improve keyboard experience.

* Update broken test snapshots.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release_note:enhancement Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.5.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants