Skip to content
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

[Logs UI] Add sorting capabilities to categories page #88051

Merged
merged 6 commits into from
Jan 18, 2021

Conversation

Kerry350
Copy link
Contributor

Summary

This PR implements #58314.

Note

For maximum anomaly score and message count this is a simple numeric sort. For the "trend percentage" there is a little more work involved as the change factor is based off of two values, and if a category is newly detected it won't have a change factor.

If there's a mixture of new items, and items with a change factor, then depending on the order the new items are prepended (ascending sort) or appended (descending order) to the sorted items.

If the list only contains new items, there will be no visual change on sort.

Testing

  • Maximum anomaly score, message count, and trend should all be sortable.
  • Maximum anomaly score should now be the default
  • In the case where the trend contains "new" items this should still work, based on the implementation above.
    • It can help to just recreate the job to test the above, and then wait for trend values to appear.

@Kerry350 Kerry350 added release_note:enhancement v8.0.0 Feature:Logs UI Logs UI feature Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.12.0 labels Jan 12, 2021
@Kerry350 Kerry350 added this to the Logs UI 7.12 milestone Jan 12, 2021
@Kerry350 Kerry350 requested a review from a team January 12, 2021 17:00
@Kerry350 Kerry350 self-assigned this Jan 12, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/logs-metrics-ui (Team:logs-metrics-ui)

@weltenwort weltenwort self-requested a review January 14, 2021 10:26
@weltenwort
Copy link
Member

@elasticmachine merge upstream

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

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

So... this sorts the 25 categories in the browser after the server already sorted them by document count and truncated them to the requested number.

Doesn't that mean that an anomaly with a very high score in a category with low document count might never show up even though the user sorts by anomaly score?

Should we delegate the sorting to ES? It'll be tricky for the trend column because these values are fetched separately. 🤔

@Kerry350
Copy link
Contributor Author

@weltenwort Yes, I think my interpretation was probably wrong here. I thought we'd be keeping the "top" nature but then allowing a sort. But in hindsight that doesn't really make sense.

Should we delegate the sorting to ES?

Yeah. It will largely mirror the sort implementation I did for the anomalies page.

It'll be tricky for the trend column because these values are fetched separately.

Yeah. I'm just looking at the way fetchTopLogEntryCategoryHistograms depends on fetchTopLogEntryCategories and so on. That is pretty tricky, I'll see if I can come up with something there 🤔

@weltenwort
Copy link
Member

Maybe we can reduce the scope to not make the trend sortable? (@mukeshelastic)

@Kerry350
Copy link
Contributor Author

Maybe we can reduce the scope to not make the trend sortable?

👍 Makes sense to me. The "new" aspect makes things more complicated as well. It's not a particularly good field for a primary sort.

@Kerry350
Copy link
Contributor Author

Kerry350 commented Jan 14, 2021

I've pushed the changes that switch this for server side sorting for maximum anomaly score and message count. I've also reversed anything to do with trend sorting.

@mukeshelastic Do you think this is a suitable compromise? It's not trivial to sort on the trend as the values are derived from different places. There might be a way to combine the queries, but it's certainly not a small change.

Copy link
Member

@weltenwort weltenwort left a comment

Choose a reason for hiding this comment

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

@Kerry350, thanks for revisiting the server-side sorting. It works great for the count and the anomaly score and is implemented very cleanly. 👍

While I'd still like to hear from @mukeshelastic about the trend column, I think this can stand on its own and could be merged at your convenience.

@@ -29,6 +30,8 @@ export const TopCategoriesSection: React.FunctionComponent<{
sourceId: string;
timeRange: TimeRange;
topCategories: LogEntryCategory[];
sortOptions: SortOptions;
changeSortOptions: ChangeSortOptions;
Copy link
Member

Choose a reason for hiding this comment

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

total nit: Do we want to keep the on* naming schema for such functions?

Suggested change
changeSortOptions: ChangeSortOptions;
onChangeSortOptions: ChangeSortOptions;

@@ -14,13 +14,33 @@ import {
createDatasetsFilters,
} from './common';

import { CategorySort } from '../../../../common/http_api/log_analysis';
Copy link
Member

Choose a reason for hiding this comment

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

This import makes my slightly uncomfortable because it couples the query to the HTTP types, but I'm not sure it's worth dwelling on.

Do you think it would be worth it to duplicate that type here so they are technically independent but happen to line up without conversion (how convenient)?

Alternatively we could move that type to a location like common/log_analysis/log_entry_rate_analysis.ts so it's independent of the HTTP layer. 🤔

…entry_categories.ts

Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
@Kerry350
Copy link
Contributor Author

@weltenwort I'm going to merge this without the further type / naming changes as I think they'll make more sense addressed alongside #79770. As part of that I've lifted a few (other) bits into common for a similar reason already.

changeSortOptions is also the naming used over on the anomalies page. So I'll just try to adjust everything in one place, as imports from http_api permeate a few places (the log_entry_anomalies query for example is also setup like this one, to import sort and pagination from http_api).

But my intention is to hoist them to common locations that aren't http_api and then have the HTTP types decorated with those common types.

@weltenwort
Copy link
Member

Sounds good, thank you!

@Kerry350
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
infra 2.7MB 2.7MB +1.3KB

History

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

@Kerry350 Kerry350 merged commit 53f4b21 into elastic:master Jan 18, 2021
Kerry350 added a commit to Kerry350/kibana that referenced this pull request Jan 18, 2021
* Add sorting capabilities to categories page

Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
@mukeshelastic
Copy link

@Kerry350 @weltenwort Thanks for looking into this. I am good with not making the trend column sortable?.

Kerry350 added a commit that referenced this pull request Jan 18, 2021
* Add sorting capabilities to categories page

Co-authored-by: Felix Stürmer <weltenwort@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Logs UI Logs UI feature release_note:enhancement Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants