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

[Alerting] Fix the charts on Log Threshold Rule Alert Detail page #160321

Merged
merged 14 commits into from
Jun 27, 2023

Conversation

simianhacker
Copy link
Member

Summary

This PR fixes #160320 by changing the chart from the CriterionPreview chart, borrowed from the Log Threshold Rule, to an embedded Lens visualization that represents the correct document count in one chart. I also took the liberty of changing the ratio chart to use the same technique for consistency sake.

Count with multiple conditions

Before

image

After

image

Count with multiple conditions and a group by

Before

image

After

image

Ratio with multiple conditions

Before

image

After

image

Ratio with multiple conditions and a group by

Before

image

After

image

@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.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@simianhacker simianhacker added release_note:fix auto-backport Deprecated - use backport:version if exact versions are needed v8.9.0 v8.10.0 labels Jun 22, 2023
@simianhacker simianhacker marked this pull request as ready for review June 23, 2023 14:01
@simianhacker simianhacker requested a review from a team as a code owner June 23, 2023 14:01
Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

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

I tested it locally, and it works with count and ratio as excepted.

  • I left a comment regarding the annotation color to use the them color.
  • I would suggest moving the chart and its definitions to the @kbn/observability-alert-details package to reuse it for the Threshold Rule alert details.
    • We maintain only one chart
    • There is an overlap between the rules' use cases.

@simianhacker simianhacker enabled auto-merge (squash) June 26, 2023 15:28
Copy link
Contributor

@benakansara benakansara left a comment

Choose a reason for hiding this comment

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

I noticed a difference in log count between this chart and Log spikes analysis chart. Is this expected?

For this chart, criteria is passed as KQL and group by is passed as filter. In the Log spikes, we are passing everything as filter. Depending on the criteria, there can be different filter types - term, match, match_phrase, range which are used in rule executor. Do they provide same results as KQL generated for this chart?

Also, timestamp and label in the tooltip look different. Should we make it consistent between both charts?

Screenshot 2023-06-27 at 10 59 25 Screenshot 2023-06-27 at 10 59 47 Screenshot 2023-06-27 at 12 21 59

@walterra
Copy link
Contributor

@benakansara Explain Log Rate Spikes uses a dynamic agg interval for the chart similar to the chart in Discover, it's not based on the alerts lookback interval. So in the example screenshot it looks like the agg interval for the upper chart is 5 minutes, for Explain Log Rate Spikes it's 1 minute. That should explain the differences for the counts.

@benakansara
Copy link
Contributor

@walterra I did sum of the last 5 minutes of data from Logs Spike chart, and thought it should match with data in first chart. But they did not match. Is the doc count shown in the Logs spike chart the exact number of logs or is it average number of logs in 1 minute interval (for above screenshot)?

@walterra
Copy link
Contributor

@benakansara Oh sorry I missed you summed up the individual buckets. it should match in this case since it's only a few docs that don't trigger random sampling. I suggest to create a separate issue for this to unblock this PR, it's something we can look into separately and it might have already been the case with the previous chart too.

@benakansara
Copy link
Contributor

benakansara commented Jun 27, 2023

@walterra sure, I will create an issue for investigation. I am not sure which chart has issue, and whether it is really an issue or not.

Created: #160618

@benakansara
Copy link
Contributor

Also, timestamp and label in the tooltip look different. Should we make it consistent between both charts?

@simianhacker what do you think about this?

@simianhacker
Copy link
Member Author

Also, timestamp and label in the tooltip look different. Should we make it consistent between both charts?

@benakansara We can change the label to read "document count" instead of "Logs" but the timestamp is configured by Lens.

@simianhacker
Copy link
Member Author

I updated the labels to match.

@simianhacker simianhacker requested a review from benakansara June 27, 2023 15:15
@benakansara
Copy link
Contributor

We have different timestamp in tooltip in each of the charts on the page. We can look into it later to see if there is a way to streamline this.

@benakansara
Copy link
Contributor

@simianhacker Do you have any insight on mismatching doc count and difference in query building between first chart and spike analysis chart? Could this be an issue or not really?

I noticed a difference in log count between this chart and Log spikes analysis chart. Is this expected?

For this chart, criteria is passed as KQL and group by is passed as filter. In the Log spikes, we are passing everything as filter. Depending on the criteria, there can be different filter types - term, match, match_phrase, range which are used in rule executor. Do they provide same results as KQL generated for this chart?

Also, timestamp and label in the tooltip look different. Should we make it consistent between both charts?

Screenshot 2023-06-27 at 10 59 25 Screenshot 2023-06-27 at 10 59 47 Screenshot 2023-06-27 at 12 21 59

Copy link
Contributor

@benakansara benakansara left a comment

Choose a reason for hiding this comment

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

LGTM. Tested locally, and works as expected.

I left a question which may not be related to this PR.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
infra 1471 1473 +2

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.0MB 2.0MB -4.7KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
infra 119.8KB 119.8KB +23.0B
Unknown metric groups

async chunk count

id before after diff
infra 28 29 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 14 16 +2
infra 53 52 -1
securitySolution 413 417 +4
total +5

Total ESLint disabled count

id before after diff
enterpriseSearch 15 17 +2
infra 63 62 -1
securitySolution 492 496 +4
total +5

History

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

@simianhacker simianhacker merged commit a8322d2 into elastic:main Jun 27, 2023
kibanamachine pushed a commit that referenced this pull request Jun 27, 2023
…60321)

## Summary

This PR fixes #160320 by changing the chart from the `CriterionPreview`
chart, borrowed from the Log Threshold Rule, to an embedded Lens
visualization that represents the correct document count in one chart. I
also took the liberty of changing the ratio chart to use the same
technique for consistency sake.

## Count with multiple conditions

### Before

<img width="736" alt="image"
src="https://github.com/elastic/kibana/assets/41702/6c6a27ea-f8e4-491f-8a12-261d0ed13dcb">

### After

<img width="736" alt="image"
src="https://github.com/elastic/kibana/assets/41702/9b18ebe9-e911-4e40-8911-bee55cd7d245">

## Count with multiple conditions and a group by

### Before

<img width="736" alt="image"
src="https://github.com/elastic/kibana/assets/41702/7b9462da-55b2-4f54-ba09-3c55b372ae2c">

### After

<img width="736" alt="image"
src="https://github.com/elastic/kibana/assets/41702/b268caed-242f-430a-ade0-14bf491ec899">

## Ratio with multiple conditions

### Before

<img width="736" alt="image"
src="https://github.com/elastic/kibana/assets/41702/55b8dfa2-7789-433b-bffd-e412bdb08b3f">

### After

<img width="736" alt="image"
src="https://github.com/elastic/kibana/assets/41702/a029bf8a-3ba1-4e16-87bd-097ebc526a4e">

## Ratio with multiple conditions and a  group by

### Before

<img width="736" alt="image"
src="https://github.com/elastic/kibana/assets/41702/61ddf1e9-c5ad-4546-a539-15a51ee563c0">

### After

<img width="736" alt="image"
src="https://github.com/elastic/kibana/assets/41702/15b0aaa3-4ef9-47f6-baba-24869feae77e">

(cherry picked from commit a8322d2)
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.9

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

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

kibanamachine added a commit that referenced this pull request Jun 27, 2023
…ge (#160321) (#160661)

# Backport

This will backport the following commits from `main` to `8.9`:
- [[Alerting] Fix the charts on Log Threshold Rule Alert Detail page
(#160321)](#160321)

<!--- Backport version: 8.9.7 -->

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

<!--BACKPORT [{"author":{"name":"Chris
Cowan","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-06-27T16:18:31Z","message":"[Alerting]
Fix the charts on Log Threshold Rule Alert Detail page (#160321)\n\n##
Summary\r\n\r\nThis PR fixes #160320 by changing the chart from the
`CriterionPreview`\r\nchart, borrowed from the Log Threshold Rule, to an
embedded Lens\r\nvisualization that represents the correct document
count in one chart. I\r\nalso took the liberty of changing the ratio
chart to use the same\r\ntechnique for consistency sake.\r\n\r\n## Count
with multiple conditions\r\n\r\n### Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/6c6a27ea-f8e4-491f-8a12-261d0ed13dcb\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/9b18ebe9-e911-4e40-8911-bee55cd7d245\">\r\n\r\n##
Count with multiple conditions and a group by\r\n\r\n###
Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/7b9462da-55b2-4f54-ba09-3c55b372ae2c\">\r\n\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/b268caed-242f-430a-ade0-14bf491ec899\">\r\n\r\n##
Ratio with multiple conditions\r\n\r\n### Before\r\n\r\n<img
width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/55b8dfa2-7789-433b-bffd-e412bdb08b3f\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/a029bf8a-3ba1-4e16-87bd-097ebc526a4e\">\r\n\r\n\r\n##
Ratio with multiple conditions and a group by\r\n\r\n###
Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/61ddf1e9-c5ad-4546-a539-15a51ee563c0\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/15b0aaa3-4ef9-47f6-baba-24869feae77e\">","sha":"a8322d27117415e94d69da43c682b0d399cb344c","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","auto-backport","v8.9.0","v8.10.0"],"number":160321,"url":"https://github.com/elastic/kibana/pull/160321","mergeCommit":{"message":"[Alerting]
Fix the charts on Log Threshold Rule Alert Detail page (#160321)\n\n##
Summary\r\n\r\nThis PR fixes #160320 by changing the chart from the
`CriterionPreview`\r\nchart, borrowed from the Log Threshold Rule, to an
embedded Lens\r\nvisualization that represents the correct document
count in one chart. I\r\nalso took the liberty of changing the ratio
chart to use the same\r\ntechnique for consistency sake.\r\n\r\n## Count
with multiple conditions\r\n\r\n### Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/6c6a27ea-f8e4-491f-8a12-261d0ed13dcb\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/9b18ebe9-e911-4e40-8911-bee55cd7d245\">\r\n\r\n##
Count with multiple conditions and a group by\r\n\r\n###
Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/7b9462da-55b2-4f54-ba09-3c55b372ae2c\">\r\n\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/b268caed-242f-430a-ade0-14bf491ec899\">\r\n\r\n##
Ratio with multiple conditions\r\n\r\n### Before\r\n\r\n<img
width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/55b8dfa2-7789-433b-bffd-e412bdb08b3f\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/a029bf8a-3ba1-4e16-87bd-097ebc526a4e\">\r\n\r\n\r\n##
Ratio with multiple conditions and a group by\r\n\r\n###
Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/61ddf1e9-c5ad-4546-a539-15a51ee563c0\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/15b0aaa3-4ef9-47f6-baba-24869feae77e\">","sha":"a8322d27117415e94d69da43c682b0d399cb344c"}},"sourceBranch":"main","suggestedTargetBranches":["8.9"],"targetPullRequestStates":[{"branch":"8.9","label":"v8.9.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/160321","number":160321,"mergeCommit":{"message":"[Alerting]
Fix the charts on Log Threshold Rule Alert Detail page (#160321)\n\n##
Summary\r\n\r\nThis PR fixes #160320 by changing the chart from the
`CriterionPreview`\r\nchart, borrowed from the Log Threshold Rule, to an
embedded Lens\r\nvisualization that represents the correct document
count in one chart. I\r\nalso took the liberty of changing the ratio
chart to use the same\r\ntechnique for consistency sake.\r\n\r\n## Count
with multiple conditions\r\n\r\n### Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/6c6a27ea-f8e4-491f-8a12-261d0ed13dcb\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/9b18ebe9-e911-4e40-8911-bee55cd7d245\">\r\n\r\n##
Count with multiple conditions and a group by\r\n\r\n###
Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/7b9462da-55b2-4f54-ba09-3c55b372ae2c\">\r\n\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/b268caed-242f-430a-ade0-14bf491ec899\">\r\n\r\n##
Ratio with multiple conditions\r\n\r\n### Before\r\n\r\n<img
width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/55b8dfa2-7789-433b-bffd-e412bdb08b3f\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/a029bf8a-3ba1-4e16-87bd-097ebc526a4e\">\r\n\r\n\r\n##
Ratio with multiple conditions and a group by\r\n\r\n###
Before\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/61ddf1e9-c5ad-4546-a539-15a51ee563c0\">\r\n\r\n###
After\r\n\r\n<img width=\"736\"
alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/41702/15b0aaa3-4ef9-47f6-baba-24869feae77e\">","sha":"a8322d27117415e94d69da43c682b0d399cb344c"}}]}]
BACKPORT-->

Co-authored-by: Chris Cowan <[email protected]>
@simianhacker
Copy link
Member Author

@benakansara I think the only problem is they are NOT using the same interval. The chart at the top is using the interval defined by the look back window of the rule. The spike analysis is using the "auto" bucketing. When I originally put the chart on the page, it used the same bucketing as the spike analysis, the charts matched exactly. BUT I felt like the minimum bucket size for the chart at the top of the page should reflect the look back window of the rule.

@grabowskit @maciejforcone Do you all have opinions on which interval we should use? We can easily use the same interval as the spike analysis OR should we push to have the spike analysis match the look back window of the alert? I can go either way.

@simianhacker simianhacker deleted the fix-log-threshold-charts branch April 17, 2024 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed release_note:fix v8.9.0 v8.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Alerting] Log Threshold alert detail page should only show one chart per condition.
9 participants