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

Add entity definition support #804

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ For a quick overview, these are the assets typically found in an Elastic Package
* Security rules
* CSP (cloud security posture) rule templates
* SLOs
* Entity definitions
* Other
* fields.yml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func ValidateKibanaObjectIDs(fsys fspath.FS) specerrors.ValidationErrors {

for _, objectFile := range objectFiles {
filePath := objectFile.Path()
if strings.Contains(filePath, "kibana/entity_definition/") {
continue
}

objectID, err := objectFile.Values("$.id")
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"fmt"
"path"
"slices"
"strings"

"github.com/elastic/package-spec/v3/code/go/internal/fspath"
"github.com/elastic/package-spec/v3/code/go/internal/pkgpath"
Expand Down Expand Up @@ -43,6 +44,9 @@ func ValidateKibanaNoDanglingObjectIDs(fsys fspath.FS) specerrors.ValidationErro
}
for _, objectFile := range objectFiles {
filePath := objectFile.Path()
if strings.Contains(filePath, "kibana/entity_definition/") {
continue
}

currentReference, err := getCurrentObjectReference(objectFile, fsys.Path(filePath))
if err != nil {
Expand Down
9 changes: 6 additions & 3 deletions spec/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
##
- version: 3.4.0-next
changes:
- description: Add support for content packages.
type: enhancement
link: https://github.com/elastic/package-spec/pull/777
- description: Add support for content packages.
type: enhancement
link: https://github.com/elastic/package-spec/pull/777
- description: Add support for `entity definition` assets.
type: enhancement
link: https://github.com/elastic/package-spec/pull/804
- version: 3.3.0-next
changes:
- description: Add support for `slo` assets.
Expand Down
13 changes: 13 additions & 0 deletions spec/integration/kibana/spec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,20 @@ spec:
pattern: '^{PACKAGE_NAME}-.+\.json$'
forbiddenPatterns:
- '^.+-(ecs|ECS)\.json$' # ECS suffix is forbidden
- description: Folder containing Kibana Entity definition assets
type: folder
name: entity_definition
required: false
contents:
- description: An Entity Definition asset file
type: file
contentMediaType: "application/json"
pattern: '^{PACKAGE_NAME}-.+\.json$'
versions:
- before: 3.4.0
patch:
- op: remove
path: "/contents/14" # remove Entity definition definitions
- before: 3.3.0
patch:
- op: remove
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"definition": {
"id": "services_from_logs",
"name": "Extract services from logs",
"managed": true,
"type": "service",
"indexPatterns": ["logs-*"],
"identityFields": ["service.name"],
"displayNameTemplate": "{{service.name}}",
"metadata": [
"data_stream.type"
],
"history": {
"timestampField": "@timestamp",
"interval": "1m",
"settings": {
"frequency": "2m"
}
},
"version": "1.0.0"
}
}
2 changes: 1 addition & 1 deletion test/packages/good_v3/manifest.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
format_version: 3.3.0
format_version: 3.4.0
name: good_v3
title: Good package
description: This package is good for format version 3
Expand Down