diff --git a/code/go/internal/validator/semantic/types.go b/code/go/internal/validator/semantic/types.go index 088355805..3f7f9decb 100644 --- a/code/go/internal/validator/semantic/types.go +++ b/code/go/internal/validator/semantic/types.go @@ -23,6 +23,7 @@ type field struct { Unit string `yaml:"unit"` MetricType string `yaml:"metric_type"` Dimension bool `yaml:"dimension"` + External string `yaml:"external"` Fields fields `yaml:"fields"` } diff --git a/code/go/internal/validator/semantic/validate_dimensions.go b/code/go/internal/validator/semantic/validate_dimensions.go index 7f1250030..6306d3c35 100644 --- a/code/go/internal/validator/semantic/validate_dimensions.go +++ b/code/go/internal/validator/semantic/validate_dimensions.go @@ -17,6 +17,11 @@ func ValidateDimensionFields(pkgRoot string) errors.ValidationErrors { } func validateDimensionField(fieldsFile string, f field) errors.ValidationErrors { + if f.External != "" { + // TODO: External fields can be used as dimensions, but we cannot resolve + // them at this point, so accept them as they are by now. + return nil + } if f.Dimension && !isAllowedDimensionType(f.Type) { return errors.ValidationErrors{fmt.Errorf(`file "%s" is invalid: field "%s" of type %s can't be a dimension, allowed types for dimensions: %s`, fieldsFile, f.Name, f.Type, strings.Join(allowedDimensionTypes, ", "))} } diff --git a/code/go/internal/validator/semantic/validate_dimensions_test.go b/code/go/internal/validator/semantic/validate_dimensions_test.go index 8bc349fe9..f0d9e6829 100644 --- a/code/go/internal/validator/semantic/validate_dimensions_test.go +++ b/code/go/internal/validator/semantic/validate_dimensions_test.go @@ -69,6 +69,15 @@ func TestValidateDimensionFields(t *testing.T) { }, valid: false, }, + { + title: "external field as dimension should be supported", + field: field{ + Name: "container.id", + External: "ecs", + Dimension: true, + }, + valid: true, + }, } for _, c := range cases { diff --git a/test/packages/time_series/data_stream/example/fields/ecs.yml b/test/packages/time_series/data_stream/example/fields/ecs.yml new file mode 100644 index 000000000..1706e98b6 --- /dev/null +++ b/test/packages/time_series/data_stream/example/fields/ecs.yml @@ -0,0 +1,3 @@ +- name: container.id + external: ecs + dimension: true diff --git a/versions/1/changelog.yml b/versions/1/changelog.yml index 9db113e37..96ff72e03 100644 --- a/versions/1/changelog.yml +++ b/versions/1/changelog.yml @@ -13,6 +13,9 @@ - description: Add email, time_zone and url config types. type: enhancement link: https://github.com/elastic/package-spec/pull/241 + - description: Add support for dimension fields from external sources. + type: enhancement + link: https://github.com/elastic/package-spec/pull/248 - version: 1.2.0 changes: - description: Add tag support for elastic export