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

Use groupBy when groupings is not populated correctly #189672

Merged
merged 10 commits into from
Sep 19, 2024

Conversation

kdelemme
Copy link
Contributor

@kdelemme kdelemme commented Jul 31, 2024

Summary

This PR fallbacks on the groupBy/instanceId fields to build the preview data queries when groupings is empty. It can be empty because the SLO has not been updated for more than its lookback window.
Previously, we would show all events regardless of the groupBy/InstanceId values, bringing confusion to the end user.

Testing

  1. Create some SLO (7days) with data forge running, using two groupBy keys.
  2. After a while, stop data forge, and delete the previously generated sli documents for one SLO instanceId only.
  3. When going to the slo details page, the good vs bad events chart should show the correct number of events

@obltmachine
Copy link

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

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

@kdelemme kdelemme added release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.16.0 labels Jul 31, 2024
@kdelemme kdelemme marked this pull request as ready for review July 31, 2024 19:43
@kdelemme kdelemme requested a review from a team as a code owner July 31, 2024 19:43
@elasticmachine
Copy link
Contributor

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

Comment on lines +526 to +532
} else if (options.instanceId && options.instanceId !== ALL_VALUE && options.groupBy) {
const instanceIdPart = options.instanceId.split(',');
const groupByPart = Array.isArray(options.groupBy) ? options.groupBy : [options.groupBy];
groupByPart.forEach((groupBy, index) => {
filter.push({
term: { [groupBy]: instanceIdPart[index] },
});
Copy link
Member

@simianhacker simianhacker Jul 31, 2024

Choose a reason for hiding this comment

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

Hum... when the slo.instanceId is created, we sort the values to keep them stable. It's not guaranteed that the first value will match the first field.

I wonder if we shouldn't change the ingest pipeline to ensure the first value matches first field, the second value matches the second field, and so on... To do this, we could simplify the ingest pipeline by getting rid of the painless script and replace it with:

   {
     dot_expander: {
       path: 'slo.groupings',
       field: '*',
     },
   },
   {
     set: {
       field: 'entity.id',
       value: [slo.groupBy]
         .flat()
         .map((field) => `{{{slo.groupings.${field}}}}`)
         .join(','),
     },
   },

This would ensure that first value in the slo.instanceId would map back to the first field in the group by list. Since this quirk only affects SLOs who's data stopped reporting and were multi-group-by-values (probably a small subset of our users), it would work for most everyone else. Anyone who had a multi-group-by slo.instanceId that had an issue could use the _reset command to get the new ingest pipeline and things would start working as expected.

Thoughts?

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 think that's a good approach. I like the simplification. We probably need to handle the case where groupBy is * but otherwise looks good to me

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 came up with this 2 processors to handle no groupings. Local testing seems to work fine without group, with 1 and many groups

 {
      dot_expander: {
        path: 'slo.groupings',
        field: '*',
        ignore_failure: true,
        if: 'ctx.slo.groupings != null',
      },
    },
    {
      set: {
        description: 'Generated the instanceId field based on the groupings field',
        field: 'slo.instanceId',
        value: [slo.groupBy].flat().includes(ALL_VALUE)
          ? ALL_VALUE
          : [slo.groupBy]
              .flat()
              .map((field) => `{{{slo.groupings.${field}}}}`)
              .join(','),
      },
    },

@botelastic botelastic bot added the ci:project-deploy-observability Create an Observability project label Jul 31, 2024
@kdelemme kdelemme requested a review from simianhacker August 1, 2024 14:17
@kdelemme kdelemme enabled auto-merge (squash) August 1, 2024 19:58
@kdelemme
Copy link
Contributor Author

kdelemme commented Aug 8, 2024

@simianhacker can you take a look this week please?

@kdelemme
Copy link
Contributor Author

@simianhacker Do you have time to review this please?

@kdelemme kdelemme added the backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) label Sep 19, 2024
@kibana-ci
Copy link
Collaborator

kibana-ci commented Sep 19, 2024

💚 Build Succeeded

  • Buildkite Build
  • Commit: 7bd7bc0
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-189672-7bd7bc03a206

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
observability 463.6KB 463.6KB -43.0B
slo 853.3KB 853.3KB -25.0B
total -68.0B

History

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

Copy link
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

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

Did Testing with multiple group-by fields and things looks normal !!

@kdelemme kdelemme merged commit c509747 into elastic:main Sep 19, 2024
23 checks passed
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 19, 2024
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.x

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Sep 19, 2024
…#193456)

# Backport

This will backport the following commits from `main` to `8.x`:
- [Use groupBy when groupings is not populated correctly
(#189672)](#189672)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Kevin
Delemme","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-19T17:19:23Z","message":"Use
groupBy when groupings is not populated correctly
(#189672)","sha":"c509747a7b59da5eec63d95792404b1ad3559131","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","Team:obs-ux-management","v8.16.0"],"title":"Use
groupBy when groupings is not populated
correctly","number":189672,"url":"https://github.com/elastic/kibana/pull/189672","mergeCommit":{"message":"Use
groupBy when groupings is not populated correctly
(#189672)","sha":"c509747a7b59da5eec63d95792404b1ad3559131"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/189672","number":189672,"mergeCommit":{"message":"Use
groupBy when groupings is not populated correctly
(#189672)","sha":"c509747a7b59da5eec63d95792404b1ad3559131"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Kevin Delemme <[email protected]>
@kdelemme kdelemme deleted the slo/preview-groupby branch September 20, 2024 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:prev-minor Backport to (8.x) the previous minor version (i.e. one version back from main) ci:project-deploy-observability Create an Observability project release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.16.0 v9.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants