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

Introduce "docs_only" attribute for subsets #1909

Merged
merged 15 commits into from
May 16, 2022

Conversation

ebeahan
Copy link
Member

@ebeahan ebeahan commented May 10, 2022

Overview

Introduce a new attribute for subset file definitions, docs_only. Setting docs_only: True only filters the field to include it in the ECS docs.

Example usage

name: event
fields:
  base:
    fields:
      "@timestamp": {}
  agent:
    fields: "*"
  dll:
    fields: "*"
  ecs:
    fields: "*"
  process:
    fields:
      same_as_process:
        docs_only: True

Use case

Support for situations like the process.same_as_parent field, which is only populated in process reuses. In the current documentation, a field still must be defined and described at the top level. The field's description includes the guidance of which reuses contains the field.

Design

The changes to support docs_only were added to schema.subset_filter. If docs_only is defined on any subset fields, these extra steps take place:

  • A second subset with only docs_only fields is created
  • Filter a list of docs_only fields using this second subset
  • Remove any docs_only fields from the main fields list. Removing the fields prevents them from appearing in any other artifacts.
  • Pass the filtered list into the ascii_doc generator alongside the main fields.

Resolves #1907

@ebeahan ebeahan self-assigned this May 10, 2022
@ebeahan ebeahan requested a review from a team as a code owner May 10, 2022 21:22
@ebeahan ebeahan added 8.2.1 and removed 8.2.0 labels May 10, 2022
@ebeahan
Copy link
Member Author

ebeahan commented May 10, 2022

I've also added the two initial entries mentioned as examples in #1907 to the docs-only defs: process.same_as_process and process.entry_meta.type: ECS docs preview

With the refactoring, I've removed these entries. We can handle it in a separate PR.

@ebeahan ebeahan force-pushed the docs-only-fields branch from 6f78aca to 3445773 Compare May 13, 2022 16:41
@ebeahan ebeahan force-pushed the docs-only-fields branch from 3445773 to d045c26 Compare May 13, 2022 16:42
@ebeahan ebeahan changed the title Add support for "docs-only" fields definitions Introduce "docs_only" attribute for subsets May 13, 2022
@ebeahan ebeahan requested a review from a team May 16, 2022 14:10
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

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

LGTM.

@ebeahan ebeahan merged commit 9ca4cf3 into elastic:main May 16, 2022
@ebeahan ebeahan deleted the docs-only-fields branch May 16, 2022 20:14
ebeahan added a commit to ebeahan/ecs that referenced this pull request May 16, 2022
* add docs_only_fields

* first pass at apply docs_only to subset filter config

* linting

* update field details

* handle case with no docs_only fields declared

* removed defining docs_only fields here

* cleanup

* add new unit tests

* document in usage

* revert changes to beats generator and default_fields list

* extra import

* changelog

* moving entry

(cherry picked from commit 9ca4cf3)
ebeahan added a commit to ebeahan/ecs that referenced this pull request May 16, 2022
* add docs_only_fields

* first pass at apply docs_only to subset filter config

* linting

* update field details

* handle case with no docs_only fields declared

* removed defining docs_only fields here

* cleanup

* add new unit tests

* document in usage

* revert changes to beats generator and default_fields list

* extra import

* changelog

* moving entry

(cherry picked from commit 9ca4cf3)

# Conflicts:
#	CHANGELOG.next.md
@ebeahan
Copy link
Member Author

ebeahan commented May 16, 2022

💚 All backports created successfully

Status Branch Result
8.2

Questions ?

Please refer to the Backport tool documentation

ebeahan added a commit that referenced this pull request May 17, 2022
* add docs_only_fields

* first pass at apply docs_only to subset filter config

* linting

* update field details

* handle case with no docs_only fields declared

* removed defining docs_only fields here

* cleanup

* add new unit tests

* document in usage

* revert changes to beats generator and default_fields list

* extra import

* changelog

* moving entry

(cherry picked from commit 9ca4cf3)
ebeahan added a commit that referenced this pull request May 17, 2022
* add docs_only_fields

* first pass at apply docs_only to subset filter config

* linting

* update field details

* handle case with no docs_only fields declared

* removed defining docs_only fields here

* cleanup

* add new unit tests

* document in usage

* revert changes to beats generator and default_fields list

* extra import

* changelog

* moving entry

(cherry picked from commit 9ca4cf3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Documentation-only field descriptions
3 participants