[AO][SERVERLESS] Fix Custom Threshold rule tests for Serverless #166942
[AO][SERVERLESS] Fix Custom Threshold rule tests for Serverless #166942fkanout merged 8 commits intoelastic:mainfrom
Conversation
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
|
Pinging @elastic/actionable-observability (Team: Actionable Observability) |
💚 Build Succeeded
Metrics [docs]Canvas Sharable Runtime
History
To update your PR or re-run it, just comment with: cc @fkanout |
|
🧪 Flaky test runner for both Serverless and Statefull ENVs (200 runs for each) |
|
|
maryam-saeidi
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
👍🏻
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'; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
I see, where can I learn more about the discussion you mentioned?
There was a problem hiding this comment.
As I mentioned, it was on Slack, I need to search the thread.
maryam-saeidi
left a comment
There was a problem hiding this comment.
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.
|
Hey all, this PR introduced a few type errors and was reverted with 706f6fa |

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