Skip to content

[DOCS] Create open API specification for find rules#147061

Merged
lcawl merged 8 commits intoelastic:mainfrom
lcawl:rule-status-docs
Dec 12, 2022
Merged

[DOCS] Create open API specification for find rules#147061
lcawl merged 8 commits intoelastic:mainfrom
lcawl:rule-status-docs

Conversation

@lcawl
Copy link
Contributor

@lcawl lcawl commented Dec 6, 2022

Summary

Relates to #137240, #144566

This PR adds the new last_run and next_run properties to the find rule API docs.

It also creates the open API specification for that endpoint and generates a preview in the Kibana appendix. Some of the descriptions for response properties are obtained from https://github.com/elastic/kibana/blob/main/x-pack/plugins/alerting/README.md

@github-actions
Copy link
Contributor

github-actions bot commented Dec 6, 2022

Documentation preview:

@lcawl lcawl added release_note:skip Skip the PR/issue when compiling release notes docs v8.7.0 v8.6.1 Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// Feature:Alerting labels Dec 6, 2022
@lcawl lcawl marked this pull request as ready for review December 6, 2022 17:31
@lcawl lcawl requested review from a team as code owners December 6, 2022 17:31
@elasticmachine
Copy link
Contributor

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

Copy link
Contributor

@szabosteve szabosteve left a comment

Choose a reason for hiding this comment

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

LGTM!

@pmuellr
Copy link
Contributor

pmuellr commented Dec 8, 2022

The data field response from the find API will end up being the "rule shape" that is returned from several APIs - I think for that shape, we'll want to figure out how to describe that shape separately, and then refer to that description from here.
Ideally the doc would just be a link to the type, so the resulting doc for the API would be a lot smaller.

Wondering if we should add one more API - maybe GET /api/alerting/rule/{id}, which is pretty simple, so we can get the structure working. I'm not sure there's any other "shared structures" like that. Or that could be a follow-on PR ...

We'll also have to figure out what we want to do eventually with actions[X].params. Would be nice to point, somehow, to all the potential shapes, which are based on actions[X].connector_type_id(each connector type defines a different shape).

Or maybe we want some other structure for these.

@guskovaue
Copy link
Contributor

Hi, @lcawl !

Looked at docs preview:
Screenshot 2022-12-08 at 22 04 15

And see Query Parameter under each parameter. Is it expected?

@lcawl
Copy link
Contributor Author

lcawl commented Dec 8, 2022

And see Query Parameter under each parameter. Is it expected?

You're right, that's unnecessary, so I'll add it to our list of known issues with this generator tool. Hopefully we won't be using it for too long, however, and this wouldn't be one that I'd consider a blocker.

@lcawl
Copy link
Contributor Author

lcawl commented Dec 8, 2022

The data field response from the find API will end up being the "rule shape" that is returned from several APIs - I think for that shape, we'll want to figure out how to describe that shape separately, and then refer to that description from here. Ideally the doc would just be a link to the type, so the resulting doc for the API would be a lot smaller.

For other endpoints, if there are objects / arrays etc that are used in multiple places, we've ended up putting them in reusable "schemas" like the ones for cases here: https://github.com/elastic/kibana/tree/main/x-pack/plugins/cases/docs/openapi/components/schemas I fully expect that as I get more rule API specs generated, we'll have re-used schemas here too.

An advantage of having them fully described in the spec rather than just pointing elsewhere is that they're then tested against the examples that we provide in the spec (e.g. it tells me if I've got a null in a field that's not nullable).

Wondering if we should add one more API - maybe GET /api/alerting/rule/{id}, which is pretty simple, so we can get the structure working. I'm not sure there's any other "shared structures" like that. Or that could be a follow-on PR ...

My preference would be to get one in (so all the other structure and folders are in place), then break out schema objects as needed. I was getting very big PRs which were harder to review otherwise.

We'll also have to figure out what we want to do eventually with actions[X].params. Would be nice to point, somehow, to all the potential shapes, which are based on actions[X].connector_type_id(each connector type defines a different shape).

I'm open to any level of discussions for the preferred shape and all the pertinent properties! It'll be interesting to see how much overlap there is between the connector API specs and the rule API specs (and how we can avoid any redundancies). For the cases APIs, I relied on the oneOf/anyOf/allOf functionality to group the different types of supported connector properties. I'm hoping the same will be feasible here too!

@guskovaue
Copy link
Contributor

@elasticmachine merge upstream

@elastic elastic deleted a comment from kibanamachine Dec 11, 2022
@kibana-ci
Copy link

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled in files

id before after diff
osquery 1 2 +1

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
fleet 60 66 +6
osquery 109 115 +6
securitySolution 445 451 +6
total +20

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
fleet 69 75 +6
osquery 110 117 +7
securitySolution 521 527 +6
total +21

History

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

@lcawl lcawl merged commit d862f46 into elastic:main Dec 12, 2022
@lcawl lcawl deleted the rule-status-docs branch December 12, 2022 19:39
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Dec 12, 2022
@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.6

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 Dec 12, 2022
…147391)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[DOCS] Create open API specification for find rules
(#147061)](#147061)

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

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

<!--BACKPORT [{"author":{"name":"Lisa
Cawley","email":"lcawley@elastic.co"},"sourceCommit":{"committedDate":"2022-12-12T19:36:44Z","message":"[DOCS]
Create open API specification for find rules
(#147061)","sha":"d862f46c2a6930a9f219ec5287dcce7bb286b305","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Alerting","release_note:skip","Team:ResponseOps","docs","v8.7.0","v8.6.1"],"number":147061,"url":"https://github.com/elastic/kibana/pull/147061","mergeCommit":{"message":"[DOCS]
Create open API specification for find rules
(#147061)","sha":"d862f46c2a6930a9f219ec5287dcce7bb286b305"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/147061","number":147061,"mergeCommit":{"message":"[DOCS]
Create open API specification for find rules
(#147061)","sha":"d862f46c2a6930a9f219ec5287dcce7bb286b305"}},{"branch":"8.6","label":"v8.6.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Lisa Cawley <lcawley@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Feature:Alerting release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.6.0 v8.6.1 v8.7.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants