Skip to content

[Osquery] Enables OpenAPI documentation for 5 new Osquery 9.4 API endpoints#262810

Merged
tomsonpl merged 11 commits intoelastic:mainfrom
tomsonpl:oas-docs-osquery
Apr 17, 2026
Merged

[Osquery] Enables OpenAPI documentation for 5 new Osquery 9.4 API endpoints#262810
tomsonpl merged 11 commits intoelastic:mainfrom
tomsonpl:oas-docs-osquery

Conversation

@tomsonpl
Copy link
Copy Markdown
Contributor

@tomsonpl tomsonpl commented Apr 13, 2026

Summary

Enables OpenAPI documentation for the new Osquery 9.4 API endpoints introduced behind the feature flag. Now that the feature flag has been enabled in #262693, the API specs can be published to the official bundled documentation.

Changes

Enabled x-labels for new endpoints

  • Replaced empty x-labels: [] with x-labels: [serverless, ess] on the following endpoints that were previously gated behind the feature flag:
    • POST /api/osquery/packs/{id}/copy — Copy an osquery pack
    • POST /api/osquery/saved_queries/{id}/copy — Copy an osquery saved query
    • GET /api/osquery/scheduled_results/{scheduleId}/{executionCount} — Get scheduled action results
    • GET /api/osquery/scheduled_results/{scheduleId}/{executionCount}/results — Get scheduled query results
    • GET /api/osquery/history — Get unified execution history
  • Removed associated TODO comments that were placeholder markers for the FF-gated state.

Added parameter-level descriptions to OpenAPI schemas

  • Added description fields at the parameter level (alongside the existing schema-level descriptions) for scheduled_results.schema.yaml and unified_history.schema.yaml. This ensures proper rendering in API documentation tools that read parameter-level metadata.

Endpoints added to public API documentation

Method Path Description
GET /api/osquery/history Get a unified, time-sorted history of live, rule-triggered, and scheduled osquery executions
POST /api/osquery/packs/{id}/copy Copy an osquery pack
POST /api/osquery/saved_queries/{id}/copy Copy an osquery saved query
GET /api/osquery/scheduled_results/{scheduleId}/{executionCount} Get scheduled action results (metadata)
GET /api/osquery/scheduled_results/{scheduleId}/{executionCount}/results Get scheduled query results (data rows)

Context

This is the documentation counterpart to #262693 which enabled the Osquery 9.4 feature flag. The endpoints themselves were already implemented and functional; this PR makes them visible in the official Kibana OpenAPI specification so they appear in public API docs and can be consumed by API clients and tooling.

Risk Matrix

Risk Level Mitigation
Runtime behavior change None Documentation-only change — no server code modified
API contract change None Endpoints already existed and were serving traffic; this only adds their OAS documentation
Breaking change None No existing API signatures are modified

Test plan

  • Verify the bundled OpenAPI YAML files are valid by loading them in an OpenAPI viewer (e.g., Swagger UI or Redocly)
  • Confirm all five new endpoints appear in both the ESS and Serverless bundled docs
  • Verify the generated .gen.ts files are consistent with the schema YAML (run code generation and confirm no diff)
  • Confirm CI passes — type checks, linting, and bundled doc validation

@tomsonpl
Copy link
Copy Markdown
Contributor Author

/ci

@tomsonpl tomsonpl changed the title Oas docs osquery [Osquery] Enables OpenAPI documentation for 5 new Osquery 9.4 API endpoints Apr 13, 2026
@tomsonpl tomsonpl requested a review from szwarckonrad April 13, 2026 18:16
@tomsonpl tomsonpl marked this pull request as ready for review April 13, 2026 18:16
@tomsonpl tomsonpl requested a review from a team as a code owner April 13, 2026 18:16
@tomsonpl tomsonpl requested a review from pzl April 13, 2026 18:16
@tomsonpl tomsonpl self-assigned this Apr 13, 2026
@tomsonpl tomsonpl added release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution Osquery backport:version Backport to applied version labels v9.4.0 labels Apr 13, 2026
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/security-defend-workflows (Team:Defend Workflows)

@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod Bot requested a review from a team as a code owner April 13, 2026 18:44
Copy link
Copy Markdown
Contributor

@natasha-moore-elastic natasha-moore-elastic left a comment

Choose a reason for hiding this comment

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

Left a couple of suggestions, but looks good overall!
One thing that we should add to the new endpoints is x-state to indicate the lifecycle (Generally available) and version applicability (Added in 9.4.0).

name: id
required: true
schema:
$ref: '#/components/schemas/PackId'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The description of this param is The ID of the pack you want to run, retrieve, update, or delete.
Could we update it to either include ...or copy, or to be more generic like The ID of the pack you want to perform the action on.

nullable: true
type: string
UnifiedHistoryRow:
oneOf:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When rendered in bump, these show as two separate tabs with the same name (object-2)
Image

Could we do something similar to this
https://github.com/elastic/kibana/blob/main/x-pack/solutions/security/plugins/security_solution/docs/openapi/ess/security_solution_detections_api_2023_10_31.bundled.schema.yaml#L8599 so that when rendered the tabs have specific names:

Image

data:
edges:
- {}
- {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just checking these are supposed to be empty?

# Conflicts:
#	oas_docs/output/kibana.serverless.yaml
#	oas_docs/output/kibana.yaml
#	x-pack/platform/plugins/shared/osquery/docs/openapi/ess/osquery_api_2023_10_31.bundled.schema.yaml
#	x-pack/platform/plugins/shared/osquery/docs/openapi/serverless/osquery_api_2023_10_31.bundled.schema.yaml
@tomsonpl
Copy link
Copy Markdown
Contributor Author

Thanks @natasha-moore-elastic, I applied the suggestions 👍

@elastic-vault-github-plugin-prod elastic-vault-github-plugin-prod Bot requested a review from a team as a code owner April 16, 2026 10:54
@elasticmachine
Copy link
Copy Markdown
Contributor

⏳ Build in-progress, with failures

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #129 / AgentBuilder Endpoints SML internal API POST /internal/agent_builder/sml/_attach attaches SML items and persists conversation attachment refs
  • [job] [logs] FTR Configs #94 / Serverless Observability - Deployment-agnostic Synthetics API integration tests SyntheticsAPITests PrivateLocationCreateMonitor handles auto upgrading policies
  • [job] [logs] FTR Configs #94 / Serverless Observability - Deployment-agnostic Synthetics API integration tests SyntheticsAPITests PrivateLocationCreateMonitor handles auto upgrading policies

History

cc @tomsonpl

Copy link
Copy Markdown
Contributor

@szwarckonrad szwarckonrad left a comment

Choose a reason for hiding this comment

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

LGTM, good job! Clean PR, everything looks correct. The x-labels flip, x-state annotations, parameter-level descriptions, discriminator on UnifiedHistoryRow, and the improved examples all look solid.

@tomsonpl tomsonpl merged commit 3259c92 into elastic:main Apr 17, 2026
18 checks passed
@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.4

https://github.com/elastic/kibana/actions/runs/24576089641

@kibanamachine
Copy link
Copy Markdown
Contributor

💔 All backports failed

Status Branch Result
9.4 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 262810

Questions ?

Please refer to the Backport tool documentation

@tomsonpl tomsonpl added backport:skip This PR does not require backporting and removed backport:version Backport to applied version labels labels Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:skip This PR does not require backporting Osquery release_note:skip Skip the PR/issue when compiling release notes Team:Defend Workflows “EDR Workflows” sub-team of Security Solution v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants