Skip to content

[AO][SERVERLESS] Fix Custom Threshold rule tests for Serverless #166942

Merged
fkanout merged 8 commits intoelastic:mainfrom
fkanout:fix-custom-threshold-rule-serverless-tests
Sep 29, 2023
Merged

[AO][SERVERLESS] Fix Custom Threshold rule tests for Serverless #166942
fkanout merged 8 commits intoelastic:mainfrom
fkanout:fix-custom-threshold-rule-serverless-tests

Conversation

@fkanout
Copy link
Copy Markdown
Contributor

@fkanout fkanout commented Sep 21, 2023

Summary

Fixes #165569
Fixes #166617
Fixes #166618
Fixes #166619
Fixes #166620

@fkanout fkanout requested a review from a team September 21, 2023 13:50
@ghost
Copy link
Copy Markdown

ghost commented Sep 21, 2023

🤖 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!)

@fkanout fkanout added release_note:skip Skip the PR/issue when compiling release notes Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" v8.11.0 labels Sep 21, 2023
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/actionable-observability (Team: Actionable Observability)

@fkanout fkanout self-assigned this Sep 21, 2023
@kibana-ci
Copy link
Copy Markdown

kibana-ci commented Sep 22, 2023

💚 Build Succeeded

  • Buildkite Build
  • Commit: 555cc28
  • Kibana Serverless Image: docker.elastic.co/kibana-ci/kibana-serverless:pr-166942-555cc28c2791

Metrics [docs]

Canvas Sharable Runtime

The Canvas "shareable runtime" is an bundle produced to enable running Canvas workpads outside of Kibana. This bundle is included in third-party webpages that embed canvas and therefor should be as slim as possible.

id before after diff
module count - 5615 +5615
total size - 6.0MB +6.0MB

History

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

cc @fkanout

@fkanout
Copy link
Copy Markdown
Contributor Author

fkanout commented Sep 22, 2023

🧪 Flaky test runner for both Serverless and Statefull ENVs (200 runs for each)
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/3212

@fkanout
Copy link
Copy Markdown
Contributor Author

fkanout commented Sep 22, 2023

Waiting for @XavierM inputs as on serverless, we could create a Custom threshold rule with apm consumer, where we should not

@fkanout
Copy link
Copy Markdown
Contributor Author

fkanout commented Sep 25, 2023

flakiness-free
Screenshot 2023-09-25 at 10 40 19

Copy link
Copy Markdown
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

Nice job! 👏🏻

Overall LGTM, just added some clarification questions.

describe('Custom Threshold rule - AVG - PCT - FIRED', () => {
const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default';
const ALERT_ACTION_INDEX = 'alert-action-threshold';
// DATE_VIEW should match the index template:
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.

👍🏻

This is about index_patterns field, right?

const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default';
// DATE_VIEW should match the index template:
// x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json
const DATE_VIEW = 'kbn-data-forge-fake_hosts';
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.

Can we expose this const from the package and use it both inside the package and in the integration tests instead of defining them multiple times?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@maryam-saeidi, this value should not be part of the package as it depends on the test we are performing. e.g., for this rule and this test, we are using the template of fake_host.
But later, we could use a different type of data, we need to define another template and another DATA_VIEW.

Copy link
Copy Markdown
Member

@maryam-saeidi maryam-saeidi Sep 28, 2023

Choose a reason for hiding this comment

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

Do you mean we will add other metrics besides fake_host in the future so the DATA_VIEW will be different? Can we have multiple DATA_VIEWs exposed when we add more scenarios?

Would you have any suggestions about improving the current case and not relying on the comment? It can be tricky to debug when the data view in the package is changed, as in the package, we don't have a connection between the logic and what is used in tests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Do you mean we will add other metrics besides fake_host in the future so the DATA_VIEW will be different? Can we have multiple DATA_VIEWs exposed when we add more scenarios?

We could.

There is always room for improvement, but for the current tests and data, it's totally okay.

expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold');
expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql(
`${protocol}://${hostname}:${port}/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)`
// Added the S to protocol.getUrlParts as not returning the correct value.
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.

Does it mean our code is not working correctly, or is the test environment setup incorrect?

If I recall correctly, the protocol is part of the base path config. Do you think we can update the config then, or will it create an issue?
I want to understand why we have this mismatch in the first place.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@maryam-saeidi it's a package that we don't own. I checked the code and discussed it with the team on Slack. It returns HTTP by default when KIBANA_HOST (if not mistaken) is not provided, which is the case for serverless.

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.

I see, where can I learn more about the discussion you mentioned?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As I mentioned, it was on Slack, I need to search the thread.

Copy link
Copy Markdown
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

I added a comment here, it would be nice if there is an idea about how to avoid issue in case someone changes data view in the package.

Also, if you found the thread, please share.

@fkanout fkanout merged commit 4c1ca7e into elastic:main Sep 29, 2023
@kibanamachine kibanamachine added the backport:skip This PR does not require backporting label Sep 29, 2023
jbudz added a commit that referenced this pull request Sep 29, 2023
@jbudz
Copy link
Copy Markdown
Contributor

jbudz commented Sep 29, 2023

Hey all, this PR introduced a few type errors and was reverted with 706f6fa

https://buildkite.com/elastic/kibana-on-merge/builds/36016

fkanout added a commit that referenced this pull request Oct 2, 2023
)

## Summary
Revert the revert for #166942 💪🏻 

Fixes #165569
Fixes #166617
Fixes #166618
Fixes #166619
Fixes #166620
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment