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

[ResponseOps][Rules] OAS schema registration for Rule APIs #188445

Merged
merged 12 commits into from
Jul 24, 2024

Conversation

js-jankisalvi
Copy link
Contributor

@js-jankisalvi js-jankisalvi commented Jul 16, 2024

Summary

Issue: #187574

This PR updates request and response schemas below for rule APIs to generate OAS documentation:

  • POST /api/alerting/rule/{id?}
  • GET /api/alerting/rule/{id}
  • DELETE /api/alerting/rule/{id}
  • PUT /api/alerting/rule/{id}
  • GET /api/alerting/rules/_find
  • POST /api/alerting/rule/{rule_id}/alert/{alert_id}/_mute

How to test

  1. Start ES
  2. Add server.oas.enabled: true to kibana.dev.yml
  3. Start Kibana yarn start --no-base-path
  4. curl -s -uelastic:changeme http://localhost:5601/api/oas\?pathStartsWith\=/api/alerting/rule/ | jq
  5. For find api run curl -s -uelastic:changeme http://localhost:5601/api/oas\?pathStartsWith\=/api/alerting/rules/ | jq

@js-jankisalvi js-jankisalvi added release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Alerting/RulesFramework Issues related to the Alerting Rules Framework v8.16.0 labels Jul 16, 2024
@js-jankisalvi js-jankisalvi self-assigned this Jul 16, 2024
@js-jankisalvi js-jankisalvi requested a review from a team as a code owner July 16, 2024 14:34
@elasticmachine
Copy link
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

}),
{ meta: { description: 'History of the rule run.' } }
),
calculated_metrics: schema.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.

Couldn't find any docs, comments or example which could help explain this metrics. Would be great if someone can suggest description for calculated_metrics object.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about "Calculation of different percentiles and success ratio"?

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

Tested and it is working as expected!

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

cc @js-jankisalvi

Copy link
Contributor

@adcoelho adcoelho left a comment

Choose a reason for hiding this comment

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

Tested and works 👌

Copy link
Contributor

@JiaweiWu JiaweiWu left a comment

Choose a reason for hiding this comment

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

code LGTM! I will approve when @lcawl looks over the descriptions and gives it a green light 😄

@@ -26,7 +26,9 @@ export const muteAlertRoute = (
summary: `Mute an alert`,
},
validate: {
params: muteAlertParamsSchemaV1,
request: {
params: muteAlertParamsSchemaV1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we specify the 403 here? Since we have the RuleTypeDisabledError in 42, which sends out a custom error body. If so we should version that schema well

Copy link
Contributor

Choose a reason for hiding this comment

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

@lcawl what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cnasikas has created an issue to handle 4xx and 5xx errors for all routes.
Is it fine if I handle error response and its schema versioning in a separate PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, that seems fine to me!

},
response: {
200: {
body: () => ruleResponseSchemaV1,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here this can also 403

@js-jankisalvi
Copy link
Contributor Author

Updated all response with description here as per this PR.

Copy link
Contributor

@lcawl lcawl left a comment

Choose a reason for hiding this comment

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

Awesome! Added some feedback on the strings but otherwise LGTM!

@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

✅ unchanged

History

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

cc @js-jankisalvi

Copy link
Contributor

@JiaweiWu JiaweiWu left a comment

Choose a reason for hiding this comment

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

LGTM!

@js-jankisalvi js-jankisalvi merged commit 9422ef9 into elastic:main Jul 24, 2024
39 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label Jul 24, 2024
@js-jankisalvi js-jankisalvi deleted the oas-schema-rules-api branch July 24, 2024 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Alerting/RulesFramework Issues related to the Alerting Rules Framework release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v8.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants