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

[SLO] paginated api for groups #175190

Merged
merged 1 commit into from
Jan 23, 2024
Merged

Conversation

mgiota
Copy link
Contributor

@mgiota mgiota commented Jan 22, 2024

Fixes #174330

This PR creates the paginated API for groups, without summary for now. Summary data will come in a follow up PR

@mgiota mgiota self-assigned this Jan 22, 2024
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@mgiota mgiota changed the base branch from main to slo_group_feature January 22, 2024 08:32
@mgiota mgiota marked this pull request as ready for review January 22, 2024 09:22
@mgiota mgiota requested a review from a team as a code owner January 22, 2024 09:22
@mgiota mgiota marked this pull request as draft January 22, 2024 09:33
@mgiota mgiota force-pushed the slo_group_feature branch from de7f3b6 to 48642b1 Compare January 22, 2024 09:45
@mgiota mgiota force-pushed the api_for_groups branch 2 times, most recently from 6061030 to 5f2f2d9 Compare January 22, 2024 10:05
@mgiota mgiota marked this pull request as ready for review January 22, 2024 10:06
Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Just one note on the api versioning. Otherwise LGTM

@@ -123,6 +133,8 @@ const sloWithSummaryResponseSchema = t.intersection([
t.type({ summary: summarySchema }),
]);

const sloGroupsResponseSchema = t.record(t.string, t.number);
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is behind a feature flag, it's fine to start with the result being a Record<group, number of element in group> but when we introduce more stats in the response, we'll have to change the results to either an array or a Record<group, Stat Object>.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep definitely the type will change when we introduce a) the stats and b) I guess when we introduce more group by options. So it will be more like:

{
"by_tags": {
   "test": {
       total: 5,
       worstValue: ...
       ...
     },
  },
 "by_status": {
     "healthy": StatsObject,
     "violated": StatsObject
  }
},
"by_sli_indicator": {
...
}

Is it fine to keep it like this for now? Once this is merged, I will work on the summary stats, so this change very soon

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure returning all the group options (by tags, by indicator, by sttus_ at once is ideal since you'll need to handle pagination within each, and also based on the API input parameter, we explicitly ask for the group we want, i.e. groupBy: groupBySchema
I'd imagine the API being something like:

> Request
GET /api/observability/slos/groups?page=2&perPage=10&groupBy=tags
< Response
{
  total: 13
  page: 2
  perPage: 10,
  results: [
    { group: "tag-value-ccc", stats: { healthy: 82, violated: 1, degrading: 3, total: 86  } },
    { group: "tag-value-aaa", stats: { healthy: 4, violated: 0, degrading: 0, total: 4  } },
    { group: "tag-value-bbb", stats: { healthy: 0, violated: 10, degrading: 0, total: 10  } },
  ]
}

Copy link
Contributor Author

@mgiota mgiota Jan 23, 2024

Choose a reason for hiding this comment

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

Ok so in case of grouping by status for example, you say we would still have the same response like this:

> Request
GET /api/observability/slos/groups?page=2&perPage=10&groupBy=status
< Response
{
  total: 2
  page: 1
  perPage: 10,
  results: [
    { group: "healthy", stats: { healthy: 82, violated: 0, degrading: 0, total: 82  } },
    { group: "violated", stats: { healthy: 0, violated: 10, degrading: 0, total: 10  } },
  ]
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep indeed the API accepts groupBySchema. At the moment I don't make use of it, but eventually we will as part of #174329

Copy link
Contributor

Choose a reason for hiding this comment

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

Correct. For status groups the stats are not very useful (except the total) but as we add more stats they will make sense.

x-pack/plugins/observability/server/routes/slo/route.ts Outdated Show resolved Hide resolved
@botelastic botelastic bot added the Team:obs-ux-management Observability Management User Experience Team label Jan 22, 2024
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@mgiota mgiota requested a review from kdelemme January 22, 2024 22:17
@mgiota
Copy link
Contributor Author

mgiota commented Jan 22, 2024

@shahzad31 You recommended to fetch all tags in one terms aggregation and still have the UI pagination. How would I do this? I tried to remove the bucket_sort aggregation, but going to the next page didn't work well for me. It showed me the same tags with 1st page. Can you be more specific how you would do this?

@mgiota
Copy link
Contributor Author

mgiota commented Jan 22, 2024

Oh I see I think I know what you mean. Use slice to display the items I need to show based on the active page

@mgiota
Copy link
Contributor Author

mgiota commented Jan 22, 2024

@elasticmachine merge upstream

1 similar comment
@mgiota
Copy link
Contributor Author

mgiota commented Jan 23, 2024

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💔 Build Failed

Failed CI Steps

Metrics [docs]

‼️ ERROR: no builds found for mergeBase sha [48642b1]

History

  • 💔 Build #188650 failed 01a6b62037a33ce2b515ca797aef13eef4c8988a
  • 💔 Build #188636 failed 6146ada579d857cdfec1843ff6b045101157aeb1

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

cc @mgiota

@mgiota mgiota force-pushed the slo_group_feature branch from 48642b1 to df7f967 Compare January 23, 2024 13:08
@mgiota mgiota marked this pull request as draft January 23, 2024 13:12
@mgiota mgiota marked this pull request as ready for review January 23, 2024 14:19
Copy link
Contributor

@kdelemme kdelemme left a comment

Choose a reason for hiding this comment

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

Let's iterate on the API response shape in a follow-up PRs

@mgiota
Copy link
Contributor Author

mgiota commented Jan 23, 2024

Ok cool I'm merging this one and will continue with the summary data

@mgiota mgiota merged commit fa9c41f into elastic:slo_group_feature Jan 23, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:SLO Team:obs-ux-management Observability Management User Experience Team v8.13.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create an API to get paginated list of groups with summary data
5 participants